寫出下列程序的運(yùn)行結(jié)果
#include <iostream.h>class MyClass{char ch;public:MyClass();MyClass(char character);void Print();~MyClass();};MyClass::MyClass(){cout<<"This is a constructor!"<<endl;ch='a';}MyClass::MyClass(char character){cout<<"This is a constructor!"<<endl;ch=character;}void MyClass::Print(){cout<<"The value of ch is "<<ch<<endl;}MyClass::~MyClass(){cout<<"This is a destructor!"<<endl;}void main(){MyClass first,second('b');***.print();***.print();}
修改好的程序(原程序有多個錯)及運(yùn)行結(jié)果(這個是C++類基本操作)
Tags:程序
相關(guān)推薦
便查問答是一款實用的網(wǎng)絡(luò)熱門知識問答平臺,專注于分享你不知道的知識,、經(jīng)驗及生活問題,,在這里所有人都能找到答案歡迎網(wǎng)友參與討論。