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
Getting the Current Time (In Milliseconds) from the System Clock in Windows
How to Iterate Through a List of Objects in C++
C++ Tips for Code Optimization on Arm Devices
Why Gcc Does Not Use Load(Without Fence) and Store+Sfence for Sequential Consistency
Opencv - Dll Missing, But It's Not
C++ Const Keyword - Use Liberally
Simple 3X3 Matrix Inverse Code (C++)
Are C/C++ Fundamental Types Atomic
How to Use Makefiles in Visual Studio
Stl Map Should Use Find() or [N] Identifier to Find Element in Map
G++ Error:/Usr/Lib/Rpm/Redhat/Redhat-Hardened-Cc1: No Such File or Directory
Const Pointer Assign to a Pointer
Automatic Copy Files to Output During Application Building
Advice on Mocking System Calls