創作內容

2 GP

vv

作者:尖酸但中肯│2017-06-02 15:04:54│巴幣:4│人氣:240
#include <iostream>
#include <cstdlib>
using namespace std;
class Caaa
{
private:
int total,*ptr;
public:
Caaa(int num)
{
cout<<"Constructor"<<endl;
total=num;
    ptr=new int[total];
    for(int i=0;i<total;i++)
{
   ptr[i]=100;
}
    }
    
    void show(void)
{
cout<<"Show"<<endl;
for(int i=0;i<total;i++)
{
   cout<<ptr[i]<<endl;
}
    }
 
    void set(void)
{
cout<<"Set"<<endl;
cout <<"InputArray:"<<endl;
for(int i=0;i<total;i++)
{
cin >> ptr[i];
}
}
Caaa(const Caaa &Ca)
{
cout<<"Copy"<<endl;
total=Ca.total;
ptr=new int[total];
ptr=Ca.ptr;
}
~Caaa()
{
cout<<"Deconstructor"<<endl;
delete [ ] ptr;
}
};
int main (void)
{
int num=0;

cout << "Input:" << endl;
cin >> num;

Caaa cass(num);
cass.show();
cass.set();

Caaa cass1(cass);

cass.show();
cass1.show();

cout<<sizeof(cass)<<endl;
return 0;
}
引用網址:https://home.gamer.com.tw/TrackBack.php?sn=3596881
All rights reserved. 版權所有,保留一切權利

相關創作

留言共 1 篇留言

別動肝火
路過

07-05 10:22

我要留言提醒:您尚未登入,請先登入再留言

2喜歡★jerry850206 可決定是否刪除您的留言,請勿發表違反站規文字。

前一篇:中華民國鈔票面額介紹...

追蹤私訊切換新版閱覽

作品資料夾

hyzgdivina喜歡虹咲的LLer
我的小屋裡有很多又香又甜的Hoenn繪師虹咲漫畫翻譯喔!歡迎LoveLiver來我的小屋裡坐坐~看更多我要大聲說41分前


face基於日前微軟官方表示 Internet Explorer 不再支援新的網路標準,可能無法使用新的應用程式來呈現網站內容,在瀏覽器支援度及網站安全性的雙重考量下,為了讓巴友們有更好的使用體驗,巴哈姆特即將於 2019年9月2日 停止支援 Internet Explorer 瀏覽器的頁面呈現和功能。
屆時建議您使用下述瀏覽器來瀏覽巴哈姆特:
。Google Chrome(推薦)
。Mozilla Firefox
。Microsoft Edge(Windows10以上的作業系統版本才可使用)

face我們了解您不想看到廣告的心情⋯ 若您願意支持巴哈姆特永續經營,請將 gamer.com.tw 加入廣告阻擋工具的白名單中,謝謝 !【教學】