C&C++程序错误调试大全

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;
    }

 

 

发布了39 篇原创文章 · 获赞 7 · 访问量 11万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章