This might be a newbie question, but I am asking myself it anyway.
If I have a Object class defined:
Object *p = new Object();
Does this code create a pointer p, and at location p, place a Object object, correct?
这表示:
pp。编辑:回应评论:
这不是构造类的唯一方法。另一种是静态分配一个类,例如。
Parent p;
在这种情况下,您不会将指向 Parent 类的指针存储在变量 p 中,而是整个类本身。在这种情况下: