This question might be a little odd and I could not find anything about it on the web. This is mostly about the c++ syntax.
Suppose I have the following struct
struct foo
{
void someMethod();
};
Now here we could create an instance of this struct and use its method as such
foo().someMethod(); // Works fine - Create instance on stack and called its method
foo* p = new foo(); // Works fine - p points to object on the heap
Now my question is - I have seen in some places the following
foo* p = new foo; //Not new foo(); // Its missing `()` at the end;
so whats the difference between declaring foo in the following two ways for an object that does not require a parameter in the contructor
foo(); and foo;
if there is no difference in the two then why cant we do
foo.someMethod();
this is just a question that I am curious about.