注册 登录
编程论坛 C++教室

这也错了?这么简单?晕

DG中专生 发布于 2007-12-07 13:53, 802 次点击
#include<iostream>
#include<string>
using namespace std;
int main()
{
 class a{
 public:
 bool b(const int c,const int d)
 {
   return c>b?c:d;
 }
 }
 bool g;
 int e=10,f=11;
 cout<<g.b(e,f)<<endl;
 return 0;
}
3 回复
#2
DG中专生2007-12-07 14:01
#include<iostream>
#include<string>
using namespace std;
int main()
{
    class a{
    public:
    int b(const int c,const int d)
    {
      return    c>b?c:d;
    }
    };
    int g;
    int e=10,f=11;
    cout<<g.b(e,f)<<endl;
    return 0;
}
改成这样了?错误还有,哪里?谢谢
#3
中学者2007-12-07 14:07
原帖由 [bold][underline]DG中专生[/underline][/bold] 于 2007-12-7 14:01 发表 [url=http://bbs.bc-cn.net/redirect.php?goto=findpost&pid=1136101&ptid=190984][/url]
#include
#include
using namespace std;
int main()
{
     class a{
     public:
     int b(const int c,const int d)
     {
       return     c>b?c:d;
     }
     };
    int g;
     int e=10,f=11;
     cout<<g.b(e,f)<<endl;

红的地方改为:  c>d  和 a g;
#4
heyyroup2007-12-07 14:07
int g;
        int e=10,f=11;
        cout<<g.b(e,f)<<endl;
        return 0;
g要声明成类的对象才能调用类的成员函数
1