What are the C++ rules for calling the superclass constructor from a subclass one?
For example, I know in Java, you must do it as the first line of the subclass constructor (and if you don't, an implicit call to …
Why does this code:
class A
{
public:
explicit A(int x) {}
};
class B: public A
{
};
int main(void)
{
B *b = new B(5);
delete b;
}
Result in these errors:
main.cpp: In function ‘int main()’:
main.cpp:13: error: no matching function …
I have a question:
Say I have originally these classes which I can't change (let's say because they're taken from a library which I'm using):
class Animal_
{
public:
Animal_();
int getIdA()
{
return idA;
};
string getNameA()
{
return nameA;
}
private:
string nameA;
…