I need to set values for variables which are struct members(variable1,variable2) in the code below. values should be different and they are just set once for each variable(initializing).
How can I use set function for this, void setValue(const mystruct & val)
Do I need to do something with the constructor of myclass, since I get error undefined reference to mystruct::mystruct()
It still gives me an error saying undefined reference to mystruct::mystruct() in the constructor for myclass. How can I do something in the class constructor to avoid this ?
struct mystruct
{ mystruct(int _a, int _b, int _c, int _d);
int a,b,c,d;
};
class myclass
{
public:
myclass();
void setValue1(const mystruct & variable);
void setValue2(const mystruct & variable);
private:
mystruct variable1;
mystruct variable2;
};
mystruct::mystruct(int _a, int _b, int _c, int _d)
{ a = _a;
b = _b;
c = _c;
d = _d;
}
int main ()
{ myclass x;
x.setValue1 (mystruct(1,2,3,4));
}