B
Beach Potato
I guess I've been out of C++ for a while, since right now I don't seem
to get a simple solution for overriding inherited constrictors.
What worked in Borland C++ & Pascal (and Java, if I remember correctly) as:
-------------------------------------------
class Base { public: Base(); };
Base::Base() { printf("Base"); }
class Derived : Base { public: Derived(); override; };
Derived:erived() { /*inherited;*/ printf("Derived"); }
void main() { Derived d; }
///
would return "Derived"
-------------------------------------------
I could control whether I wanted to use base constructor or not with
keywords "override" and "inherited" (if I took the comments out from the
Derived constructor).
But in VC++ the keyword "override" is not defined, and no matter what I
do with constructors, results are always the same:
-------------------------------------------
class Base { public: Base(); };
Base::Base() { printf("Base"); }
class Derived : Base { public: Derived(); };
Derived:erived() { printf("Derived"); }
void main() { Derived d; }
would return "BaseDerived"
-------------------------------------------
Is there any way to make the derived constructor fully override the
base? I tried all combinations with public/protected/private to no
avail. Something very simple without an intricate C++ implementation,
that only hardcore C++ folks can understand?
I'm somewhat confused here.
to get a simple solution for overriding inherited constrictors.
What worked in Borland C++ & Pascal (and Java, if I remember correctly) as:
-------------------------------------------
class Base { public: Base(); };
Base::Base() { printf("Base"); }
class Derived : Base { public: Derived(); override; };
Derived:erived() { /*inherited;*/ printf("Derived"); }
void main() { Derived d; }
///
would return "Derived"
-------------------------------------------
I could control whether I wanted to use base constructor or not with
keywords "override" and "inherited" (if I took the comments out from the
Derived constructor).
But in VC++ the keyword "override" is not defined, and no matter what I
do with constructors, results are always the same:
-------------------------------------------
class Base { public: Base(); };
Base::Base() { printf("Base"); }
class Derived : Base { public: Derived(); };
Derived:erived() { printf("Derived"); }
void main() { Derived d; }
would return "BaseDerived"
-------------------------------------------
Is there any way to make the derived constructor fully override the
base? I tried all combinations with public/protected/private to no
avail. Something very simple without an intricate C++ implementation,
that only hardcore C++ folks can understand?
I'm somewhat confused here.