Note that there are some explanatory texts on larger screens.

plurals
  1. PODefault destructor issue, it isn't detected
    text
    copied!<p>I tried to use my own destructor instead of the default destructor but I get the following error anyhow. Does anyone know why I'm getting this?</p> <p>error:</p> <pre><code>AssignmentRepository.o: In function `ZNSt6vectorI10AssignmentSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_': c:/mingw/bin/../lib/gcc/mingw32/4.6.1/include/c++/bits/vector.tcc:308: undefined reference to `Assignment::~Assignment()' c:/mingw/bin/../lib/gcc/mingw32/4.6.1/include/c++/bits/vector.tcc:308: undefined reference to `Assignment::~Assignment()' AssignmentRepository.o: In function `ZN9__gnu_cxx13new_allocatorI10AssignmentE7destroyEPS1_': c:/mingw/bin/../lib/gcc/mingw32/4.6.1/include/c++/ext/new_allocator.h:118: undefined reference to `Assignment::~Assignment()' AssignmentRepository.o: In function `ZSt8_DestroyI10AssignmentEvPT_': c:/mingw/bin/../lib/gcc/mingw32/4.6.1/include/c++/bits/stl_construct.h:94: undefined reference to `Assignment::~Assignment()' collect2: ld returned 1 exit status </code></pre> <p>Code of the class in .h file:</p> <pre><code>#ifndef ASSIGNMENTREPOSITORY_H_ #define ASSIGNMENTREPOSITORY_H_ #include "Assignment.h" #include &lt;vector&gt; class AssignmentRepository{ private: vector &lt;Assignment&gt; assignments; public: vector &lt;Assignment&gt; getAll(); void save(Assignment); void editAssignment(Assignment); int searchById(int); void printAllAssignments(); int findByName(string name); Assignment *getAssignment(int i); ~AssignmentRepository(); }; #endif /* ASSIGNMENTREPOSITORY_H_ */ </code></pre> <p>.cpp file of the class:</p> <pre><code>int AssignmentRepository::searchById(int a){ for(unsigned i=0; i&lt;assignments.size(); i++){ if(a == assignments[i].getID()){ return i; } } return 0; } AssignmentRepository::~AssignmentRepository(){ } </code></pre> <p>Assignment.h class header:</p> <pre><code>class Assignment { private: int id; int grade; int dLine; string descrption; public: Assignment(int gr, int dl, string desc):grade(gr),dLine(dl),descrption(desc){}; ~Assignment(); void setGrade(int value) {grade = value;} void setDLine(int value) {dLine = value;} void setDescription(string value) {descrption = value;} void setID(int value) {id = value;} int getID() const{return id;} int getGrade() const{return grade;} int getDLine() const{return dLine;} string getDescription() const{return descrption;} friend ostream&amp; operator &lt;&lt; (ostream&amp; out, const Assignment&amp; assignment) { out &lt;&lt; assignment.grade &lt;&lt; " " &lt;&lt; assignment.dLine &lt;&lt; " " &lt;&lt; assignment.descrption &lt;&lt;endl; return out; } }; #endif /* ASSIGNMENT_H_ */ </code></pre>
 

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