class a{
public:
void set_value(int i){v = i;}
private:
int v;
}
class b{
public:
bool set_value(unsignedint index, int i){if((values.size() >= index)returnfalse; values.at(index).set_value(i);}
void add_a(a new_obj){values.push_back(new_obj);}
private:
std::vector<a> values;
}
void main(void)
{
a a_test;
b b_test;
b_test.add_a(a_test);
b_test.set_value(5, 100); // no crash return value false
}
is there an option/possibility to use the check and add all functions from a without an extra class b. every function from class a, needs to be defined in b, this is cumbersome.