I am new to c++ and would like to know what is the difference between calling a constructor with pointer and without pointer. By without pointer I mean with an instance of the class.
For example:
#include <iostream>
using namespace std;
class abc {
abc() {
cout << "constructor";
}
~abc() {
cout << "destructor";
}
};
int main() {
abc a;
return 0;
}
// VS
int main() {
abc* a = new abc();
delete a;
return 0;
}
Is the only difference that it's dynamically called and otherwise both are same, e.g. produce the same result?