I am new to c++. I can manage the first one. we are allocating the memory in heap. I can't understand the second case.
Myclass * classobj =new Myclass;
Myclass * classobj = new Myclass();
here is an example I am testing with ubuntu
#include<iostream>
#include <stdio.h>
using namespace std;
class myclass{
public:
int i;
int j;
myclass();
};
myclass::myclass()
{
i=5;
j=7;
}
int main()
{
myclass *classobj= new myclass;
printf("%d %d",classobj->i,classobj->j);
}
when I run the above program it is printing 5 and 7 for both "new myclass" and "new myclass()". please tell me what is the difference