c++建工程为什么不对?提示找不到complex.h,该怎么改啊! 或者大侠可以给我讲讲 5
#ifndefComplex_h#defineComplex_hclassComplex{doublereal,image;public:Complex(doublerr...
#ifndef Complex_h
#define Complex_h
class Complex
{
double real,image;
public:
Complex(double rr=0, double ii=0)
{
real=rr;
image=ii;
}
Complex(Complex &c)
{
real=c.real;
image=c.image;
}
friend void Output(Complex &c);
};
#endif
#include"iostream"
using namespace std;
#include"complex.h"
void main()
{
Complex c1,c2(4,8),c3(4,0),c4(c2);
Output(c1);
Output(c2);
Output(c3);
Output(c4);
}
#include "complex.h"
void Output(complex &c)
{
if(c.image<0)
cout<<"复数为:"<<c.real<<c.image<<'i';
else if(c.image>0)
cout<<"复数为:"<<c.real<<'+'<<c.image<<'i';
else
cout<<"复数为:"<<c.real;
cout<<'\n';
} 展开
#define Complex_h
class Complex
{
double real,image;
public:
Complex(double rr=0, double ii=0)
{
real=rr;
image=ii;
}
Complex(Complex &c)
{
real=c.real;
image=c.image;
}
friend void Output(Complex &c);
};
#endif
#include"iostream"
using namespace std;
#include"complex.h"
void main()
{
Complex c1,c2(4,8),c3(4,0),c4(c2);
Output(c1);
Output(c2);
Output(c3);
Output(c4);
}
#include "complex.h"
void Output(complex &c)
{
if(c.image<0)
cout<<"复数为:"<<c.real<<c.image<<'i';
else if(c.image>0)
cout<<"复数为:"<<c.real<<'+'<<c.image<<'i';
else
cout<<"复数为:"<<c.real;
cout<<'\n';
} 展开
1个回答
展开全部
#ifndef Complex_h
#define Complex_h
class Complex
{
double real,image;
public:
Complex(double rr=0, double ii=0)
{
real=rr;
image=ii;
}
Complex(Complex &c)
{
real=c.real;
image=c.image;
}
friend void Output(Complex &c);
};
#endif
上面这部分,新建一个文件,粘里面,然后文件名为complex.h,放到和你下面的.cpp文件同一个文件夹里
#define Complex_h
class Complex
{
double real,image;
public:
Complex(double rr=0, double ii=0)
{
real=rr;
image=ii;
}
Complex(Complex &c)
{
real=c.real;
image=c.image;
}
friend void Output(Complex &c);
};
#endif
上面这部分,新建一个文件,粘里面,然后文件名为complex.h,放到和你下面的.cpp文件同一个文件夹里
追问
fatal error C1083: Cannot open include file: 'complex.h': No such file or directory
您可以在帮帮我么?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询