您的位置:首页 > 编程语言 > C语言/C++

C++ new动态创建对象

2012-04-19 20:23 162 查看
View Code

#include "iostream"
#include "string"
using namespace std;

class Point
{
public:
Point():x(0), y(0)
{
cout<<"Default constructor called."<<endl;
cout<<x<<" "<<y<<endl;
}
private:
int x, y;

};
int main()
{
Point *ptr1=new Point[10];                                                                ;
delete[] ptr1;
}


这个例子是用来展示用new来创建

对象数组的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: