___________________________________________
#include <iostream>
using namespace std;
class A
{
public:
A():x(0),y(0){}
A(int X,int Y);
void write();
int A::*wsk1;
int (A::*w)();
int go_to_y();
int(A::*t[1])();
private:
int x,y;
};
//definitions
A:: A(int X,int Y):x(X),y(Y)
{
wsk1=&A::x;
w=&A::go_to_y;
t[0]=&A::go_to_y;
}
int A::go_to_y()
{
return y;
}
void A::write()
{
cout<<"x="<<x<<" y="<<y<<endl;
}
int main()
{
cout << "Simple class" << endl;
A o1;
A o2(1,2);
cout<<"Write basic"<<endl;
o1.write();
cout<<"Write with arguments"<<endl;
o2.write();
cout<<"Pointer to x="<<o2.wsk1<<endl;
cout<<"Pointer to function y="<<o2.w<<endl;
cout<<"Pointer to function y="<<o2.t[0]<<endl;
return 0;
}
Brak komentarzy:
Prześlij komentarz