There is a one line syntax to create an instance and pointer to it, in the heap allocation. Is there one line syntax for the same purpose but with stack allocation?
#include <iostream>
class Base {};
int main()
{
//Base* ptr = new Base(); // heap
Base base;
Base* ptr = &base; // stack
return 0;
}
I have no problem to use 2 lines, just thought maybe there is a special syntax for this case (I'm moving from Python :D)
But I wouldn't consider it "a well formatted code".