Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Derived : public Base
- {
- public :
- typedef Base super; // note that it could be hidden in
- // protected/private section, instead
- // Etc.
- } ;
- Derived(int i, int j)
- : super(i), J(j)
- {
- }
- void Derived::foo()
- {
- super::foo() ;
- // ... And then, do something else
- }
- class DerivedDerived : public Derived
- {
- public :
- typedef Derived super; // note that it could be hidden in
- // protected/private section, instead
- // Etc.
- } ;
- void DerivedDerived::bar()
- {
- super::bar() ; // will call Derived::bar
- super::super::bar ; // will call Base::bar
- // ... And then, do something else
- }
- class MyClass : public MyBase
- {
- private: // Prevents erroneous use by other classes.
- typedef MyBase inherited;
- ...
- class Base
- {
- public: virtual void foo() { ... }
- };
- class Derived: public Base
- {
- public:
- typedef Base super;
- virtual void foo()
- {
- super::foo(); // call superclass implementation
- // do other stuff
- ...
- }
- };
- class DerivedAgain: public Derived
- {
- public:
- virtual void foo()
- {
- // Call superclass function
- super::foo(); // oops, calls Base::foo() rather than Derived::foo()
- ...
- }
- };
- template <typename TText, typename TSpec>
- class Finder<Index<TText, PizzaChili<TSpec> >, PizzaChiliFinder>
- : public Finder<Index<TText, PizzaChili<TSpec> >, Default>
- {
- typedef Finder<Index<TText, PizzaChili<TSpec> >, Default> TBase;
- // …
- }
- template <typename T, size_t C, typename U>
- class A
- { ... };
- template <typename T>
- class B : public A<T,99,T>
- { ... };
- template <class C>
- struct MakeAlias : C
- {
- typedef C BaseAlias;
- };
- class Derived : public Base
- {
- private:
- typedef Base Super;
- };
- class Derived : public MakeBaseAlias<Base>
- {
- // Can refer to Base as BaseAlias here
- };
Add Comment
Please, Sign In to add comment