a. "new types may not be defined in a return type" error
class 类名
{
private:
public:
protected:
}
如果你的类是如此声明的,那么编译过程将不可避免的出现: "new types may not be defined in a return type" error 。如何避免?类声明结束时别忘了加上分号(;)吧!
#include <iostream>
using namespace std;
class Tadd
{
public:
int add(int a ,int b)
{
return a+b;
}
double add(double x,double y)
{
return x+y;
}
} ------------>add ";"
int main()
{
Tadd m;
cout << "sam1="<<m.add(2,3)<<endl;
cout << "sam2="<<m.add(2.3,3.6)<<endl;
}