1宣告一個 People類,要求
0至少有id (字串) 、age (int)等成員變數;
②實作建構式;
③戀現解構式:
④至少有輸出id,增加age等成員函式;
⑤使用new運算子生成至少一個物件;
⑥使用delete運算子洗掉至少一個物件;
uj5u.com熱心網友回復:
有大佬嗎?幫幫我uj5u.com熱心網友回復:
這不就是c++的類嘛。。。。class People
{
public:
People(string id, int age);
~People();
private:
string id;
int age;
};
People::People(string id, int age)
{
this->id = id;
this->age = age;
}
People::~People()
{
id.clear();
}
People *p1 = new People("0001", 20);
delete p1;溜了溜了
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/233277.html
標籤:C++ 語言
