为何不能输出我想要的东西,这里到底是哪里出错了啊?
// #include <iostream>
// using namespace std;
// class Tri //自定义的类名Tri
// { double a,b,c ;
// public:
// Tri(double x , double y , double z )
// { a=x; b=y; c=z;
// cout<<"调用构造函数,周长为: "<<a+b+c<<endl;
// }
// ~Tri()//析构函数
// { cout<<"析构周长为: "<<a+b+c<<" 的三角形对象"<<endl; }
// };
// void main( )
// { Tri tria(3,4,5); //建立对象tria
// Tri(5,5,5); //调用构造函数建立临时对象,随后撤消临时对象
// cout<<"main()函数结束"<<endl;
// }
//---------------------------------------------//
#include <iostream>
using namespace std;
class Helloworld
{
protected:
int a,b,c;
public:
void show()
{
cout<<"hello world!"<<endl;
cout<<endl<<a<<endl<<b<<endl<<c<<endl;
}
// Helloworld()
// {
// a=10,b=20,c=30;
// cout<<endl<<a<<endl<<b<<endl<<c<<endl;
// }
Helloworld(int q,int w,int e)
{
q=a;
w=b;
e=c;
cout<<endl<<a<<endl<<b<<endl<<c<<endl;
}
~Helloworld()
{
cout<<"撤销!"<<endl;
}
};
void main()
{
// Helloworld a;
Helloworld b(22,33,44);
// a.show();
b.show();
}
在这一行中,我明明的赋值是所示Helloworld b(22,33,44);
但是每次都出现的不是22,33,44这些我输入的数字,而是若图所示的怪数字,这到底问题在哪儿啊??