Member Initializer Does Not Name a Non-Static Data Member or Base Class

member initializer 'SuperClass' does not name a non-static data member or base class

The error says it all:

member initializer 'SuperClass' does not name a non-static data member or base class

SuperClass is not a class. It's a class template. As such, it's not the base class of your type. The base class is a specific instantiation of the class template: SuperClass<T,S>. That's what you need:

    SubClass1(OtherClass<T> const& class1,
OtherOtherClass<T> const& class2)
: SuperClass<T,S>(class1, class2)
// ^^^^^

Member initializer does not name a non-static data member

Inside a class template, only its own name is injected for use without template arguments. You need this:

template<typename T>
struct TVector3 : public TVector2<T> {
T z;
TVector3(T _x = 0.0, T _y = 0.0, T _z = 0.0)
: TVector2<T>(_x, _y), z(_z)

Code Error: Is not a nonstatic data member or base class of

The error message is reasonably self explanatory, you are using the syntax for passing arguments to the constructor of the base class of your class but the class names you are using aren't base classes of the current class.

To initialise class members use the name of the member not its class:

Project::Project(char projectName, int sDay, int sMonth, int sYear, char supervisorName)
: statrtDate(sDay, sMonth, sYear),
: supervisor(supervisorName)
{
setProject(projectName, sDay, sMonth, sYear, supervisorName);
}

Error: className is not a nonstatic data member or base class of class className

This is the correct syntax, but constructor delegation is not supported until C++11.

Visual Studio 2012 does not purport to implement the C++11 standard. Constructor delegation is one of those things that is doesn't support.



Related Topics



Leave a reply



Submit