/* I have two classes. One is allocating memory on stack for its members while other is allocating on heap. See the below code snippet.*/
class A_Heap {
public:
A_Heap()
{
ptr = new char[256];
int_ptr = new int[1024];
}
private:
char * ptr;
int * int_ptr;
int abc;
char ch;
};
class A_Stack {
public:
A_Stack()
{
}
private:
char ptr[256];
int int_ptr[1024];
int abc;
char ch;
};
/*class A_Heap will be less efficient as allocate memory on heap causing two more context switch from user to kernel mode? */