im trying to return a local variable from a function.
typedef struct _s{
int a;
} Somestruct;
Somestruct func(){
Somestruct RET;
RET.a = 10;
}
int main(){
Somestruct var = func();
std::cout << var.a();
}
will this work? if i doesnt, what do i need to do to make it return the value i want? i have tried to do this with classes but it doesnt work. From the info i have learnt, when i return classes it just returns the pointer that points to the memory. However, i was thinking if i did structs, then it would physically return the whole data, not just a reference or pointer.