C++ error C2629: unexpected 'class B (' 以找到错误点,但不知原因;
2013-12-04 00:29
357 查看
# include <iostream> # include <string> using std::endl; using std::cin; using std::cout; class A{ public: A(int i):val(i){ cout<<"基类的构造函数"<<endl; } virtual ~A(){ cout<<"调用基类的析构"<<endl;}; virtual void get(){ cout<<"val的值:"<<val<<endl; } protected: int val; }; class B:public A{ public: B(){ cout<<"派生类B的构造函数"<<endl; } B(string s,int i):A(i),str(s){ cout<<"派生类B的构造函数"<<endl; } ~B(){ cout<<"派生类B的析构函数"<<endl; } private: string str; }; int main(){ B *b=new B("Hello world!!!",99); cout<<b->get()<<endl; delete b; return 0; }error C2629: unexpected 'class B ('在类似的错误中可以将 引用
using std::endl; using std::cin; using std::cout;
修改为
using namespace std;
错误就会消失
相关文章推荐
- 关于android编程中遇到的Could not find class 'com.swetake.util.Qrcode错误的原因及解决办法
- 关于android编程中遇到的Could not find class 'com.swetake.util.Qrcode错误的原因及解决办法
- unexpected 'class***或error C2501: missing storage-class or type specifiers 错误解决办法
- Spring 注解 AOP 出现错误::0 can't find referenced pointcut XXX 的原因
- qt 错误:request for member 'show' in 'showlist_ui', which is of non-class type 'ShowList*'
- qt 下extern 引用出错 错误:storage class specified for 'childlist'
- VC引入lib库并解决连接错误unresolved external symbol "__declspec(dllimport) const DllClass::`vftable'" (__imp_?
- linux--shell错误:syntax error near unexpected token ‘('
- 数据库连接错误 Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' 解决
- msxml3.dll 错误 '800c0005' 系统未找到指定的资源。
- msxml3.dll 错误'800c0005' 系统未找到指定的资源错误
- mysql Got a packet bigger than 'max_allowed_packet' bytes 错误原因及解决方法
- 'AjaxPro'未定义错误的原因&javascript顺序执行&AjaxPro机制
- 实时错误'3706'未找到提供程序。改程序可能未正确安装
- msxml document class EOleSysError with message '没有注册类别' 错误的解决
- VS2005编译DLL错误,error C2491: 'CMyClass::Function' : definition of dllimport function not allowed
- Android Studio 错误: 非法字符: '\ufeff' 解决方案|错误: 需要class, interface或enum
- SSH配置时错误:Class 'org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean' not foun
- coreseek(sphinx)错误:WARNING: attribute 'id' not found - IGNORING原因及解决方法
- ExtJs中的 'insertAdjacentHTML' 为空或不是对象错误原因及解决办法