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

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -