新手请教如何解决unexpected 'class'
#define ADD_H
#include <iostream.h>
#include <string.h>
class Add
{
protected:
char address[100];
int age;
public:
Add(char*addr,int ag)
{
strcpy(address,addr);
age=ag;
}
Add(Add A)
{
strcpy(address,A.address);
age=A.age;
}
void setadd(char* addr)
{
address=addr;
}
void setage(int ag)
{
age=ag;
}
void show()
{
cout<<"address is "<<address<<"and age is "<<age<<endl;
}
~Add()
{
delete[]address;
}
};
#endif
#include <iostream.h>
#include <string.h>
#include "add.h"
void main()
{
Add pers("Shanghai",10001);
Add::show();
}
运行时出现
应用.cpp
e:\【电脑】c++示例\人员\add.h(6) : error C2236: unexpected 'class' 'Add'
e:\【电脑】c++示例\人员\add.h(6) : error C2143: syntax error : missing ';' before '{'
e:\【电脑】c++示例\人员\add.h(6) : error C2447: missing function header (old-style formal list?)
e:\【电脑】c++示例\人员\scores.h(7) : error C2504: 'Add' : base class undefined
执行 cl.exe 时出错.
相关推荐
新手常见Python运行时错误汇总.docx
新手常见Python运行时错误汇总.docx
TypeError: add_code_sample_docstrings() got an unexpected keyword argument ‘tokenizer_class‘解决方案
本文主要介绍了TypeError: add_code_sample_docstrings() got an unexpected keyword argument 'tokenizer_class’解决方案,希望能对使用transformers的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案
新手常见Python运行时错误汇总.pdf
新手常见Python运行时错误汇总.pdf
Spring注释配置:Unexpected exception parsing XML document from class path resource [beans-annotation.xml]-附件资源
Spring注释配置:Unexpected exception parsing XML document from class path resource [beans-annotation.xml]-附件资源
PHP异常Parse error: syntax error, unexpected T_VAR错误解决方法
其实,这是一个非常容易解决掉的问题。在我看来,似曾相识,呵呵,最近学JavaScript可是学会了使用var声明变量。 其实,在PHP中根本不需要使用var声明的,但是当一个变量作为一个类的成员变量的时候,使用var还是没有问题的。 在外部使用var就报错Parse error: syntax error, unexpected T_VAR in…,例如我的出错信息: Parse error: syntax error, unexpected T_VAR in D:\Apache2.2\htdocs\shirdrn\page\p2\pageUtil.inc on line 34 我在测试:在


资源
