In C# classes are stored in heap, and structs are stored in stack.
Does in C++ classes and strucs are stored in the same way (assuming I create my classes and structs statically, and every member of class or struct is not allocated by new) ?
Please explain this using snippet of code below:
class B
{
int b;
}
class C
{
int c;
}
class A
{
B b;
C c;
int x;
}
struct SB
{
int sb;
}
struct SC
{
int sc;
}
struct SA
{
SB sb;
SC sc;
int x;
}
void main()
{
A a1;
A *a2 = new A;
SA sa1;
SA *sa2 = new SA;
}