I try to compile the next code but the compiler says that **`int base::i' is private **
#include <cstdlib>
#include <iostream>
class base
{
int i;
public:
base (int i=0);
void set ();
int get ();
};
class derivada:public base
{
public:
void set ();
} ;
using namespace std;
int main(int argc, char *argv[])
{
base clas1; derivada clas2;
base *ptrclas1; derivada *ptrclas2;
cout<<"Value of A using A's construtor "<<clas1.get ()<<endl;
cout<<"Value of B using A's construtor "<<clas1.get ()<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
base::base (int i)
{
this->i=i;
}
void base::set ()
{
this->i=1;
return;
}
int base::get ()
{
return (i);
}
void derivada :: set ()
{
this->i=2;
return;
}