I have a class named "obj" and another one named "aggregate" .
The second one is derived from the first one.
The class "obj" holds only an integer. The "aggregate" nothing more ( only more "methods").
class obj{
public:
int t;
}
I have a function that returns "obj"
obj pop();
and I need to assign the result of it to a variable of class "aggregate".
aggregate a;a=pop();
I try to do it like:
a=static_cast<aggregate>(pop());
a=dynamic_cast<aggregate>(pop());
Because essentially on the stack the value of the structure is passed ( so essentially an integer) I cannot understand why I should do:
a=*((aggregate*)(&pop()));