C++构造函数

xiaoxiao2026-05-16  11

class testint {public: testint(); testint(int b); //testint(testint& another); ~testint();private: int i;};testint::testint(){ cout<<"construct"<<endl;}testint::testint(int b):i(b){ cout<<"construct by " << i<<endl;}testint::~testint(){ cout<<"destruct i is "<<i<<endl;}///testint play(testint a){ return a;}int main(int argc, char* argv[]){ //printf("Hello World!\n"); testint t1 = play(4); testint t2 = play(5); testint t3 = play(t1); return 0;}///输出结果为:construct by 4destruct i is 4construct by 5destruct i is 5destruct i is 4destruct i is 4destruct i is 5destruct i is 4/// 相关资源:构造函数c语言
转载请注明原文地址: https://www.6miu.com/read-5048862.html

最新回复(0)