一个C++程序在free c中编译通过,但是在dev c++中却提示如下,各位指点一下

archeror 2004-05-08 05:34:24
#include <iostream>

using namespace std;

class count
{
private:
int num;
int result;
void trans();
public:
void setinfo(int i);
void display();
};

void count::setinfo(int i)
{
num = i;
}

void count::trans()
{

}

void count::display()
{
trans();
cout<<result<<endl;
}

int main()
{
count *cc;
cc = new count;
cc->setinfo(33);
cc->display();

return 1;
}

E:\Documents and Settings\game\My Documents\my cpp\dev\count.cpp
[Warning] In function `int main()':
34 E:\Documents and Settings\game\My Documents\my cpp\dev\count.cpp
use of `count' is ambiguous
6 E:\Documents and Settings\game\My Documents\my cpp\dev\count.cpp
first declared as `class count' here
390 C:\Dev-Cpp\include\c++\bits\stl_algo.h
also declared as `
34 E:\Documents and Settings\game\My Documents\my cpp\dev\count.cpp
`cc' undeclared (first use this function)

(Each undeclared identifier is reported only once for each

36 E:\Documents and Settings\game\My Documents\my cpp\dev\count.cpp
parse error before `;' token
E:\Documents and Settings\game\My Documents\my cpp\dev\Makefile.win
[Build Error] [count.o] Error 1

...全文
87 4 点赞 打赏 收藏 举报
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
archeror 2004-05-08
ok,多谢 julyclyde
  • 打赏
  • 举报
回复
julyclyde 2004-05-08
关键是这句:
390 E:\Dev-Cpp\include\c++\bits\stl_algo.h
also declared as ` std::iterator_traits<_Iterator>::difference_type std::count(_InputIter,

count这个字和STL库的关键字冲突。你换个就可以了
  • 打赏
  • 举报
回复
archeror 2004-05-08
#include <iostream>

using namespace std;

class count
{
private:
int num;
int result;
void trans(); //累计各位的值到个位为止
public:
void setinfo(int i); //设置num
void display();
};

void count::setinfo(int i)
{
num = i;
}

void count::trans()
{
if (num < 10 )
{
result = num;
return;
}

result = 0;
while (num > 0 )
{
result += num % 10;
num = num / 10;
}

num = result ;
trans();

}

void count::display()
{
trans();
cout<<result<<endl;
}

int main()
{

count *cc;
cc = new count;
cc->setinfo(33);
cc->display();
return 1;
}


这个是我的源程序,试试,我在free c中是可以的。但是到dev-c就不行。
  • 打赏
  • 举报
回复
newegg2002 2004-05-08

C:\Documents and Settings\613\My Documents\Untitled1.cpp compiled successfully
我用dev c++没有你所说的错误啊。。。
  • 打赏
  • 举报
回复
相关推荐
发帖
工具平台和程序库
加入

2.4w+

社区成员

C/C++ 工具平台和程序库
申请成为版主
帖子事件
创建了帖子
2004-05-08 05:34
社区公告
暂无公告