This is my first question on this forum, and i expect this will not be a dummy one.
I searched the answer everywhere but can't find it. Feel free to redirect me if the question is already answered somewhere.
How can i set a component of an object, into a bigger object ?
EDIT :
I will make a proper example if it's unclear,
BigObject.h
#include "Object.h"
Class BigObject {
private :
Object object
int number
public
BigObject(Object,int);
Object get_object();
void set_object(Object);
int get_number()
void set_number(int);
}
BigObject.cpp
#include "BigObject.cpp"
BigObject::BigObject(Object a,int b){
set_Object(a);
set_number(b);
};
Object BigObject::get_object(){ return this->object; };
void BigObject::set_object(Object a){ this->object = a};
int BigObject::get_number(){return this->number};
void BigObject::set_number(int b){this->number = b};
Object.h
#include <string>
Class Object {
private :
int bidule;
std::string machin;
public :
Object(int,std::string);
int get_int();
void set_int(int);
std::string get_string()
void set_string(std::string);
}
Object.cpp
#include "Object.h"
using namespace std;
Object::Object(int a,string b){
set_int(a);
set_string(b);
};
int Object::get_int(){return this->bidule};
void Object::set_int(int a){this->bidule = a};
string Object::get_string(){return this->machin};
void Object::set_string(string a){ this->machin = a};
question :
This does not work if i do :
BigObject.getObject().set_string("Foo");
It is not saved
cout << BigObject.getObject().get_string() << endl;
Doesn"t give foo. Why ? How can i save it in my Big Object ?