Mail Archives: djgpp/1994/08/31/11:01:24
DJGPP seems don't follow the access control rules to base classes. For the
following test program, it is supposed to have 5 errors. But DJGPP just
ignores all the access control rules, treats all the base classes public.
How it acts so wierd?
---- test program ----
#include <iostream.h>
class X
{
protected:
int i;
int j;
public:
void get_ij(void);
void put_ij(void);
};
class Y : private X // private X, not public
{
int k;
public:
int get_k(void);
void make_k(void);
};
class Z : public Y
{
public:
void f(void);
};
void X::get_ij(void)
{
cout << "Enter two numbers: ";
cin >> i >> j;
}
void X::put_ij(void)
{
cout << i << " " << j << endl;
}
int Y::get_k(void)
{
return k;
}
void Y::make_k(void)
{
k = i*j;
}
void Z::f(void)
{
i = 2; // error 1
j = 3; // error 2
}
main(void)
{
Y var;
Z var2;
var.get_ij(); // error 3
var.put_ij(); // error 4
var.make_k();
cout << var.get_k() << endl;
var2.f();
var2.put_ij(); // error 5
return 0;
}
- Raw text -