调试的时候,出来C++ config.h

cumt_TTR 2010-10-07 11:52:25
好像说我的iostream有错误,大家帮我看看:
2 j:\DEV-CPP\include\c++\3.4.2\iostream:44, from 13.11-1main.cpp In file included from j:/DEV-CPP/include/c++/3.4.2/iostream:44, from 13.11-1main.cpp

2 D:\My Documents\C++\13.11-1main.cpp from 13.11-1main.cpp

57 j:\DEV-CPP\include\c++\3.4.2\mingw32\bits\c++config.h expected unqualified-id before "namespace"

57 j:\DEV-CPP\include\c++\3.4.2\mingw32\bits\c++config.h expected `,' or `;' before "namespace"

61 j:\DEV-CPP\include\c++\3.4.2\mingw32\bits\c++config.h expected namespace-name before ';' token

61 j:\DEV-CPP\include\c++\3.4.2\mingw32\bits\c++config.h `<type error>' is not a namespace

D:\My Documents\C++\13.11-1main.cpp In function `int main()':

16 D:\My Documents\C++\13.11-1main.cpp `cout' undeclared (first use this function)

===================================================================main()
#include "cd.h"
#include <iostream>
using namespace std;
#include <cstdlib>

void Bravo(const Cd &disk);

int main()
{
Cd c1("Beatles","Capital",14,35.5);
Classic c2=Classic("Piano Sonata in B flat,Fantasia in C","Alfred Brendel",
"Philips",2,57.17);

Cd *pcd=&c1;

cout<<"Using object diretly: \n";
c1.Report();
c2.Report();
cout<<"Using type cd *pointer to objects: \n";
pcd->Report();
pcd=&c2;
pcd->Report();
cout<<"Calling a funcion with a Cd reference argument: \n";
Bravo(c1);
Bravo(c2);
cout<<"Testing assignment: ";
Classic copy;
copy=c2;
copy.Report();

system("pause");
}

void Bravo (const Cd &disk)
{
disk.Report();
}
...全文
564 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cumt_TTR 2010-10-07
  • 打赏
  • 举报
回复
嗷,好像是继承类后面没加分号,日
怎么会影响到 config.h 呢?
cumt_TTR 2010-10-07
  • 打赏
  • 举报
回复
#ifndef CD_H_
#define CD_H_

class Cd
{
private:
char performers[50];
char label[20];
int selections;
double playtime;
public:
Cd(char *sl,char *s2,int n,double x);
Cd(const Cd &d);
Cd();
virtual ~Cd();
virtual void Report()const;
Cd & operator=(const Cd &d);
};

class Classic:public Cd
{
private:
char *zp;
public:
Classic(const char *z,const char *pf,const char *lb,int sl,double pt);
Classic();
virtual ~Classic();
virtual void Report()const;
Classic & operator=(const Classic &d);
}
#endif
===================================================
3楼的,帮偶看看,谢谢
狐帝 2010-10-07
  • 打赏
  • 举报
回复
cd.h 里面是什么内容?说不定是这个cd.h的问题影响到了iostream。
另外,自定义的h文件最好include在标准头文件后面。
cumt_TTR 2010-10-07
  • 打赏
  • 举报
回复
来个人帮偶看看啊
狐帝 2010-10-07
  • 打赏
  • 举报
回复
影响的是c++config.h,这个文件被iostream间接包含。如果该加分号的时候没加分号,往往会引起后面一系列稀奇古怪的问题。所以,在编译出错时,如果确认编译器指出的位置没有错误,那么最好检查一下前面的代码是不是少了分号、括号什么的。

65,186

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧