0
I know a member startup list declares and at the same instant initializes such an attribute(s), that’s what I know so far.
In the following code:
#include <iostream> // std::cout
class Foo {
public:
const int intNum;
};
class Bar: public Foo {
public:
Bar( int x ): IntNum( x ) {}
};
int main()
{
Bar bar( 1 );
std :: cout << bar.intNum << "\n";
return 0;
}
I was trying to initialize the attribute intNum who now belongs to the class Bar for having inherited from Foo, then if intVar became Bar Why was there a mistake trying to initialize?
What’s wrong with the code?