Topic: Inheritance and Using declarations


Author: S Rayees <rayees@nest.stpt.soft.net>
Date: 1998/01/23
Raw View
Reference: 15.2.2 Inheritance and Using declarations(Pg. 392)
Stroustrup 3rd edition

Please see the code below.
The place where u put the 'using' means a lot.
Any idea?

I am using VC++ 5.0. Is this compiler specific?

#include <iostream.h>

class Base
{
public:
 virtual void foo(int){cout << "Base foo i" << endl;}
 virtual void foo(int,int){cout << "Base foo i,i" << endl;}
};

class Child : public Base
{
public:
// using Base::foo;//1'st
 void foo(double){cout << "Child foo d" << endl;}//does'nt matter if vir
or not

 using Base::foo; //2'nd
 virtual void foo(int){cout << "Child foo i" << endl;}
 virtual void foo(int,double){cout << "Child foo i,d" << endl;}
};

void main(void)
{
 Base base;
 Child child;

 base.foo(1);
 base.foo(2,2);
 child.foo(2.0);
 child.foo(2);
 child.foo(2,2.0);
 child.foo(2,2);//calls child foo(i,d) if 2'd using is used
}

I am looking forward to hearing about this. What does the standard say
about this?

regards
rayees

S Rayees
Project Engineer
A-3, Periyar
Technopark Campus
Trivandrum 695 581
phone: +91 471 417441/418972(off)  325096(res)
fax: +91 471 417442
mail to: rayees@nest.stpt.soft.net
            s_rayees@hotmail.com
http://members.tripod.com/~rayees
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]