Compiler Errors

From ODF::Wiki

Jump to: navigation, search

error: invalid use of nonstatic data member ‘nonstatic_member’

Of course, this often simply means that you are trying to access a nonstatic member in a static function. But consider this:

class Base {
  public: string base_str;
  class Sub {
    inline void func() { puts(base_str.c_str()); }
  }
}

In this case, the error means that you need to specify the upper class!

library.so: undefined reference to ‘vtable for Testclass’

Possible Code:

class BaseClass {
  virtual void func();
}
class Testclass {
  void func();
}

Don't be scared of the vtable! This simply means what it says - undefined reference. To what? To a virtual function. In this case, there was no file found with an implementation for Testclass::func().

Personal tools