#include <iostream>using namespace std;class test{int i;public:test(){cout<<"構造函數"<<endl;}~test(){cout<<"析構造函數"<<endl;}void setvalue(int m){i=m;}int getvalue(){return(i);}};void show(test &newtest){cout<<newtest.getvalue()<<endl;} test change(test newtest,int m){newtest.setvalue(m);show(newtest);return(newtest);}void main(){test mytest;mytest.setvalue(10);show(mytest);change(mytest,100);show(mytest);}上面的程序在調用show函數時,實參是對象而show的形參是對象的地址,這不是明顯的實參與形參的類型不符嗎?
- 2 回答
- 0 關注
- 98 瀏覽
添加回答
舉報
0/150
提交
取消