i keep getting this error and not sure what i have to do.
cpp(37) : error C2248: 'b' : cannot access private member declared in class 'B'
cpp(12) : see declaration of 'b'
cpp(41) : error C2248: 'b' : cannot access private member declared in class 'B'
cpp(12) : see declaration of 'b'
mainly this problem
b=n
AND
int b;
here's the whole thing
#include <iostream>
using namespace std;
class B
{
public:
B();
B(int n);
void print()const;
private:
int b;
};
B::B()
{
b=0;
}
B::B(int n)
{
cout<<"B:"<<b<<"/n";
}
class D: public B
{
public:
D();
D(int);
void print()const;
};
D::D()
{
}
D::D(int n)
{
b=n;
}
void D::print() const
{
cout<<"D:"<<b<<"/n";
}

New Topic/Question
Reply




MultiQuote







|