c++ - Can you 'redeclare' a variable in a subclass? -
is possible declare member subclass of base classes member?
e.g.
class { int a; } class b : { int b; } class foo { *baz; } class bar : foo { b *baz; //how can not shadow baz, 'redeclare' b? }
basically, bar have baz b , want 2 things: way of showing/enforcing , avoiding have cast baz everytime used in bar. intuition not possible, dont purport c++ expert.
you cannot. can redeclare return type of virtual function.
class foo { virtual *baz(); }; class bar : public foo { b *baz(); };
Comments
Post a Comment