B
Bangalore
Hi,
In the following program, eventhogh two member function declared under
private section of the derived class are accessable by derived class
pointer.
Please clarify me how can derived class pointer acess private member
functions.
private member functions
#include <stdio.h>
#include <iostream>
using namespace std;
class Base
{
public :
virtual void virFun1 (int i);
virtual void virFun2 (double d);
};
void Base :: virFun1(int i)
{
cout <<" Base :: virFun1 ::
"<<i<<endl;
}
void Base :: virFun2(double d)
{
cout <<" Base :: virFun2 ::
"<<d<<endl;
}
class Derived : public Base
{
private : // PRIVATE ????????????
virtual void virFun1 (int i);
virtual void virFun2 (double d);
};
void Derived :: virFun1(int i)
{
cout <<" Derived :: virFun1 ::
"<<i<<endl;
}
void Derived :: virFun2(double d)
{
cout <<" Derived :: virFun2 ::
"<<d<<endl;
}
int main ()
{
Base *d = new Derived;
d -> virFun1 (10);
d -> virFun2 (10.10);
}
Thanks in advance
Bangalore
In the following program, eventhogh two member function declared under
private section of the derived class are accessable by derived class
pointer.
Please clarify me how can derived class pointer acess private member
functions.
private member functions
#include <stdio.h>
#include <iostream>
using namespace std;
class Base
{
public :
virtual void virFun1 (int i);
virtual void virFun2 (double d);
};
void Base :: virFun1(int i)
{
cout <<" Base :: virFun1 ::
"<<i<<endl;
}
void Base :: virFun2(double d)
{
cout <<" Base :: virFun2 ::
"<<d<<endl;
}
class Derived : public Base
{
private : // PRIVATE ????????????
virtual void virFun1 (int i);
virtual void virFun2 (double d);
};
void Derived :: virFun1(int i)
{
cout <<" Derived :: virFun1 ::
"<<i<<endl;
}
void Derived :: virFun2(double d)
{
cout <<" Derived :: virFun2 ::
"<<d<<endl;
}
int main ()
{
Base *d = new Derived;
d -> virFun1 (10);
d -> virFun2 (10.10);
}
Thanks in advance
Bangalore