Assuming I have a class MyClass(int i)
, I know I can do:
int j = 1;
MyClass instance(j);
i.e. declare and initialize instance
in one line. Is there a short syntax that allows to do the same for a pointer to MyClass
?
MyClass *instance = new MyClass(j);
works, but the syntax has "MyClass" two times, which is a bit redundant.