45f22fa255
From-SVN: r15850
69 lines
1.1 KiB
C
69 lines
1.1 KiB
C
// Build don't link:
|
|
// GROUPS passed visibility
|
|
#include <iostream.h>
|
|
|
|
|
|
|
|
class base {
|
|
//==========
|
|
|
|
void base_priv(char * n)
|
|
{ cout << "base_priv called from: " << n << "\n"; };
|
|
|
|
protected:
|
|
|
|
void base_prot(char * n)
|
|
{ cout << "base_prot called from: " << n << "\n"; };
|
|
|
|
public:
|
|
|
|
void base_publ(char * n)
|
|
{ cout << "base_publ called from: " << n << "\n"; };
|
|
|
|
void test(char * n) { base_publ(n); base_prot(n); base_priv(n); }
|
|
|
|
}; // class base
|
|
|
|
|
|
|
|
class derived : public base { // Make this public,
|
|
//============================ // and we don't get an error
|
|
|
|
friend void derived_friend();
|
|
|
|
public :
|
|
|
|
void test(char * n) { base_publ(n); base_prot(n);}
|
|
|
|
}; // class derived
|
|
|
|
|
|
|
|
void
|
|
derived_friend()
|
|
//--------------
|
|
{
|
|
derived pd;
|
|
|
|
pd.base_publ("friend of derived class"); // Compiler error here
|
|
pd.base_prot("friend of derived class");
|
|
}
|
|
|
|
|
|
|
|
main(int argc, char *argv[])
|
|
//==========================
|
|
{
|
|
base b;
|
|
b.base_publ("base class object");
|
|
b.test("member of base class object");
|
|
cout << "\n";
|
|
|
|
derived pd;
|
|
pd.test("member of derived class object");
|
|
derived_friend();
|
|
cout << "\n";
|
|
|
|
} /* main */
|
|
|