Wednesday 2 December 2009

C++ errors

A list of annoying C++ compilation errors and how I finally resolved them:


(1)
...undefined reference to `typeinfo...
or
...Undefined reference to vtable

Solution: A base class from which classes are derived contains virtual function(s) but they are missing null bodies.

e.g.
virtual float getvalue() ;
should read:
virtual float getvalue() {} ;




(2) error: passing `const Quat' as `this' argument of `Quat& Quat::operator=(const Quat&)' discards qualifiers


Solution: A "const" type cannot be changed. I was attempting to assign a value to a const type. Created a new variable of same type (but not const).


(3) error: aggregate ‘std::stringstream ss’ has incomplete type and cannot be defined
or
error: X has incomplete type

Usually this refers to STD::X objects.
You've included but you need to include or
for files (ifstream/ofstream) and stringbuffers.



[to be continued]