Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass a vector of a Child class in to a function expecting a vector of Parent class?
    primarykey
    data
    text
    <p>I can pass in a Child to a member function expecting a Parent, however when using vectors I get a compile error saying there's no matching declaration. See the CorrelationEngineManager.cpp call to getUniqueLabels() at the bottom</p> <p>ServerEvent.h</p> <pre><code>#ifndef SERVEREVENT_H #define SERVEREVENT_H #define SERVEREVENT_COLS 3 #include "Event.h" #include &lt;vector&gt; class ServerEvent: public Event { private: public: ServerEvent(std::vector&lt;std::string&gt; tokens); void print(); }; #endif </code></pre> <p>Event.h</p> <pre><code>#ifndef EVENT_H #define EVENT_H #include &lt;string&gt; #define EVENT_STOP 0 #define EVENT_START 1 class Event { private: protected: double time; std::string label; int type; // EVENT_START OR EVENT_STOP public: }; #endif </code></pre> <p>CorrelationEngineManager.h</p> <pre><code>class CorrelationEngineManager { private: std::vector&lt;ServerEvent&gt; s_events; std::vector&lt;UPSEvent&gt; u_events; std::vector&lt;TimeRecord&gt; s_timeRecords; std::vector&lt;TimeRecord&gt; u_timeRecords; // typeOfEvent gets type of event, 0 for error, look at #defines for codes int typeOfEvent(std::vector&lt;std::string&gt;); int createTimeRecords(); std::vector&lt;std::string&gt; getUniqueLabels(std::vector&lt;Event&gt; events); public: CorrelationEngineManager(); //~CorrelationEngineManager(); int addEvent(std::vector&lt;std::string&gt; tokens); //add event given tokens void print_events(); }; </code></pre> <p>CorrelationEngineManager.cpp</p> <pre><code>int CorrelationEngineManager::createTimeRecords() { std::vector&lt;std::string&gt; u_sLabels; // unique server labels std::vector&lt;std::string&gt; u_uLabels; // unique UPS labels u_sLabels = getUniqueLabels(s_events); // u_uLabels = getUniqueLabels(u_events); return 1; } // returns a vector of unique labels, input a vector of events std::vector&lt;std::string&gt; CorrelationEngineManager::getUniqueLabels(std::vector&lt;Event&gt; events) { std::vector&lt;std::string&gt; temp; return temp; } </code></pre> <p>compile error</p> <pre><code> CorrelationEngineManager.cpp: In member function ‘int CorrelationEngineManager::createTimeRecords()’: CorrelationEngineManager.cpp:60: error: no matching function for call to ‘CorrelationEngineManager::getUniqueLabels(std::vector&lt;ServerEvent, std::allocator&lt;ServerEvent&gt; &gt;&amp;)’ CorrelationEngineManager.h:23: note: candidates are: std::vector&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; CorrelationEngineManager::getUniqueLabels(std::vector&lt;Event, std::allocator&lt;Event&gt; &gt;) make: *** [CorrelationEngineManager.o] Error 1 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload