Note that there are some explanatory texts on larger screens.

plurals
  1. POInitialize a dynamic vector list
    primarykey
    data
    text
    <p>I am trying to initialize my MedList but it's not working. Here's what I'm talking about: repository.h</p> <pre><code>#include "../domain/farmacy.h" #include "../utils/DynamicVector.h" class Repository{ private: DynamicVector&lt;Medicine&gt;* MedList; //I made it pointer so it can be dynamic public: Repository(); //constructor </code></pre> <p>repository.cpp</p> <pre><code>#include "../domain/farmacy.h" #include "repository.h" #include "../utils/DynamicVector.h" #include &lt;stdlib.h&gt; Repository::Repository(){ this-&gt;MedList=new DynamicVector&lt;Medicine&gt;::DynamicVector(); //error } </code></pre> <p>DynamicVector.h</p> <pre><code>template &lt;typename Element&gt; //this is the Dynamic Vector constructor DynamicVector&lt;Element&gt;::DynamicVector() { this-&gt;cap=10; this-&gt;len=0; this-&gt;elems=new Element[this-&gt;cap]; } </code></pre> <p>the error above is:</p> <pre><code>Multiple markers at this line - no match for 'operator=' in '((Repository*)this)-&gt;Repository::MedList = (int*)operator new(4u)' - expected type-specifier - candidate is: - expected ';' </code></pre> <p>this is the medicine class</p> <pre><code>class Medicine{ private: int ID; std::string nume; double concentratie; int cantitate; </code></pre> <p>The Dynamic Vector class:</p> <pre><code>template &lt;typename Element&gt; class DynamicVector{ private: Element* elems; int cap; int len; void resize(); void CopyToThis(const DynamicVector&amp; v); public: DynamicVector(); //constructor implicit DynamicVector(const DynamicVector&amp; ); //constructor de copiere DynamicVector&amp; operator=(const DynamicVector&amp; ); ~DynamicVector(); void addElement(Element elem); Element delElementAtPosition(int pos); Element getElementAtPosition(int pos); int getLen(); }; </code></pre> <p>What am I doing wrong? I tried a lot of variants but nothing seems to work. Could you help me?</p>
    singulars
    1. This table or related slice is empty.
    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