Topic: access modifiers and overloading resolution
Author: Alexander Krotoff <krotoff@such.srcc.msu.su>
Date: 1996/08/30 Raw View
Hello.
The question are:
Shall access modifiers affect overloading resolution
for derived class ?
Can i define member function with the same name as one access
modifier ajusts ?
Is it possibble to ajust access to one of base class overloded
methods ?
The example is:
struct A {
int f (short) { printf ("A::f(short)\n"); }
int f (int) { printf ("A::f(int)\n"); }
};
struct B: public A {
int f (char) { printf ("B::f(char)\n"); }
/* using */ A::f;
int f (long) { printf ("B::f(long)\n"); }
};
main ()
{
int a;
char b;
short e;
long g;
B c;
c.f(a);
c.f(b);
c.f(e);
c.f(g);
}
GNU complains about access modifier and method have the same
name. I have not found corresponding rules in the Jan 96 WP.
Thank you in advance.
--
Alexander N. Krotoff
Research Computer Center
Moscow State University
[ 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 ]
Author: jcouball@enableinc.com (James J. Couball)
Date: 1996/09/02 Raw View
Alexander,
It was my understanding that B::f completely hides
A::f even if the names have different signatures.
Maybe someone could help me with a reference as to
where this is written in the std?
I had to change the code to:
main ()
{
int a;
char b;
short e;
long g;
B c;
c.A::f(a);
c.f(b);
c.A::f(e);
c.f(g);
}
to get it to run in Visual C++.
James J. Couball
Enable, Inc.
[ 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 ]
Author: Alexander Krotoff <krotoff@such.srcc.msu.su>
Date: 1996/09/03 Raw View
> It was my understanding that B::f completely hides
> A::f even if the names have different signatures.
> Maybe someone could help me with a reference as to
> where this is written in the std?
I was wrong, asking the question. I missed one paragraph in the
Section 11. Everything is well defined in the section
"Using declaration" (7.3.3).
B::f do not completely hides A::f.
--
Alexander
[ 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 ]