error C2664: 'TestObject3::TestObject3' : cannot convert parameter 1 from 'int' to 'const TestObject3 &' 1> Reason: cannot convert from 'int' to 'const TestObject3' 1> No constructor could take the source type, or constructor overload resolution was ambiguous |
|
|
What is inherited from the base class? In principle, a derived class inherits every member of a base class except: * its constructor and its destructor * its operator=() members * its friends Although the constructors and destructors of the base class are not inherited themselves, its default constructor (i.e., its constructor with no parameters) and its destructor are always called when a new object of a derived class is created or destroyed. If the base class has no default constructor or you want that an overloaded constructor is called when a new derived object is created, you can specify it in each constructor definition of the derived class: derived_constructor_name (parameters) : base_constructor_name (parameters) {...} |
|
|
error: base `TestObject2' with only non-default constructor in class without a constructor |
test.cpp:13: error: base `TestObject2' with only non-default constructor in class without a constructor test.cpp: In function `int main(int, char**)': test.cpp:19: error: no matching function for call to `TestObject3::TestObject3(int)' test.cpp:13: note: candidates are: TestObject3::TestObject3(const TestObject3&) |
|
|
derived_constructor_name (parameters) : base_constructor_name (parameters) {...}