/*
Name: copy consturctor can visit private varity of its parameter
Copyright:
Author: elprup
Date: 08/10/10 09:18
Description:
*/
#include <cstdlib>
#include <iostream>
using namespace std;
class bar
{
private:
int m_bi;
};
class foo
{
public:
foo(int i=0):m_i(i){}
foo(foo& f){m_i = f.m_i;} //visit param f.m_i;
foo(bar& b){m_i = b.m_bi;} //visit param b.m_bi;
void p(){cout<<m_i<<endl;}
private:
int m_i;
};
int main()
{
foo f(3);
foo f2(f);
// f2.m_i; //wrong, can't access
f2.p(); //right, get value;
system("PAUSE");
return 0;
}