在 这个c++程序当中,关于#include<iostream.h>的疑惑
#include<iostream.h>为什么不使用c++标准?什么情况下使用c++标准,什么情况不使用c++标准?#include<iostream.h>classCC...
#include<iostream.h>为什么不使用c++标准?什么情况下使用c++标准,什么情况不使用c++标准?
#include<iostream.h>
class CComplex{
public:
CComplex(double,double);
CComplex(double &c);
CComplex add(CComplex &x);
CComplex(CComplex &);
void Print();
private:
double real;
double imag;};
CComplex::CComplex(double r=0.0,double i=0.0){
real=r;
imag=i;
cout<<"调用2个参数的构造函数"<<endl;
}
CComplex::CComplex (CComplex &c){
real=c.real;
imag=c.imag;
cout<<"调用拷贝构造函数"<<endl;}
void CComplex::Print(){
cout<<"("<<real<<","<<imag<<")"<<endl;}
void f( CComplex n){
cout<<"n=";
n.Print();
}
CComplex CComplex::add( CComplex &x){
CComplex y(real+x.real,imag+x.imag);
return y;}
void main(void){
CComplex a(3.0,4.0),b(5.6,7.9);
CComplex c(a);
cout<<"a=";
a.Print();
cout<<"c=";
c.Print();
f(b);
c=a.add(b);
c.Print();}
为什么错 展开
#include<iostream.h>
class CComplex{
public:
CComplex(double,double);
CComplex(double &c);
CComplex add(CComplex &x);
CComplex(CComplex &);
void Print();
private:
double real;
double imag;};
CComplex::CComplex(double r=0.0,double i=0.0){
real=r;
imag=i;
cout<<"调用2个参数的构造函数"<<endl;
}
CComplex::CComplex (CComplex &c){
real=c.real;
imag=c.imag;
cout<<"调用拷贝构造函数"<<endl;}
void CComplex::Print(){
cout<<"("<<real<<","<<imag<<")"<<endl;}
void f( CComplex n){
cout<<"n=";
n.Print();
}
CComplex CComplex::add( CComplex &x){
CComplex y(real+x.real,imag+x.imag);
return y;}
void main(void){
CComplex a(3.0,4.0),b(5.6,7.9);
CComplex c(a);
cout<<"a=";
a.Print();
cout<<"c=";
c.Print();
f(b);
c=a.add(b);
c.Print();}
为什么错 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询