+ 3

if the base class has a overloaded constructor, can we specify which to be called when creating a derived class from the bass class?

30th Apr 2016, 3:19 PM
Moria
1 Réponse
+ 6
Base class constructors are automatically called for you if they have no argument. If you want to call a superclass constructor with an argument, you must use the subclass's constructor initialization list. For example: class A { public: A(int foo) { // do something with foo } }; class B: public A { public: B(int foo, int bar) : A(foo) // Call the superclass constructor in the subclass' initialization list. { // do something with bar } };
26th May 2016, 1:24 PM
James Flanders
Aujourd'hui en vedette
.
1 Votes
What?
0 Votes
HTML
0 Votes
FRC Coding?
1 Votes
Quiz duel
0 Votes
AI
2 Votes
help
0 Votes
APIs
1 Votes
Create Agent
0 Votes