using "super" c++
my impression coding includes following idiom:
class subsequent : open base
{
open :
typedef bottom super; // note dark in
// protected/private section, instead
// etc.
} ;
this enables me "super" an alias base, example, constructors:
derived(int i, int j)
: super(i), j(j)
{
}
or even job slight bottom category inside the overridden version:
void derived::foo()
{
super::foo() ;
// ... then, something else
}
it even cumulative (i have still that, though):
class derivedderived : open derived
{
open :
typedef subsequent super; // note dark in
// protected/private section, instead
// etc.
} ;
void derivedderived::bar()
{
super::bar() ; // derived::bar
super::super::bar ; // base::bar
// ... then, something else
}
anyway, i "typedef super" unequivocally useful, example, bottom presumably plain and/or templated.
the fact super implemented java, good c# (where called "base", unless i'm wrong). nonetheless c++ lacks keyword.
so, questions:
- is typedef super common/rare/never seen formula work with?
- is typedef super ok (i.e. cunning strong reasons it)?
- should "super" good thing, should rather stereotyped c++, by typedef adequate already?
edit: roddy mentionned fact typedef should private. meant any subsequent category means but redeclaring it. nonetheless i speculation also hinder super::super chaining (but who's gonna cry that?).
edit 2: now, months after massively controlling "super", i wholeheartedly establish roddy's viewpoint: "super" should private. i upvote answer twice, nonetheless i speculation i can't.
Comments
Post a Comment