#include <iostream>
using std::cout;
using std::endl;
class b{
public:
void set_mem_b(int value){
b_mem = value;
}
int get_mem_b() const{
return b_mem;
}
private:
int b_mem;
};
class a{
public:
void set(int x, int mem_class_b){
num = x;
a_mem.set_mem_b(mem_class_b);
}
int get() const {return num;}
int get_mem_b() const {
return a_mem.get_mem_b();
}
private:
int num;
b a_mem;
};
int main(){
a obj;
obj.set(45,-7);
cout << "obj.get() = " << obj.get() << endl;
cout << "obj.get_mem_b() = " << obj.get_mem_b() << endl;
return 0;
}
No comments:
Post a Comment