C++关于类和结构体问题
书本上的小程序,结构体也可以跟类一样包含函数吗?#include<iostream>
using namespace std;
struct Complex{
private:
double r;
double i;
public:
void init(double rr,double ii){r=rr;i=ii;}
double real(){return r;}
double image(){return i;}
};
void main()
{
Complex a;
a.init(2,3);
cout<<a.real()<<"+"<<a.image()<<"i"<<endl;
}
调试运行失败fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt