ranadhir27
January 24th, 2002, 10:09 PM
i have a compilation problem in the following sample
testvirutal.h
-------------
#include "stdio.h"
class B{
public:
B(int i){xnt=i; printf("entered constructor B\n");}
int returnol(){return xnt;}
protected:
int xnt;
};
class D:public B{
public:
D(int i):B(i){printf("entered constructor D\n");};
using B::returnol;
char* returnol(char* p){return p;}
};
testmain.cpp
=============
#include "testvirtual.h"
void main()
{
D d(10);
D* sd=&d;
int ret;
char* r="dsgdg";
char* q;
q=sd->returnol(r);
ret=sd->returnol();
}
the error is
testvirtual.h:17: cannot adjust access to `int B::returnol()' in `class D'
testvirtual.h:16: because of local method `char * D::returnol(char *)' with same name
I thought that 'using' keyword should unhide the base method.what's the problem?
testvirutal.h
-------------
#include "stdio.h"
class B{
public:
B(int i){xnt=i; printf("entered constructor B\n");}
int returnol(){return xnt;}
protected:
int xnt;
};
class D:public B{
public:
D(int i):B(i){printf("entered constructor D\n");};
using B::returnol;
char* returnol(char* p){return p;}
};
testmain.cpp
=============
#include "testvirtual.h"
void main()
{
D d(10);
D* sd=&d;
int ret;
char* r="dsgdg";
char* q;
q=sd->returnol(r);
ret=sd->returnol();
}
the error is
testvirtual.h:17: cannot adjust access to `int B::returnol()' in `class D'
testvirtual.h:16: because of local method `char * D::returnol(char *)' with same name
I thought that 'using' keyword should unhide the base method.what's the problem?