用string错误 问题
//temph.h/////#ifndef_PP_#define_PP_#include<string>classPP{public:inti;stringa;};#en...
//temph.h/////
#ifndef _PP_
#define _PP_
#include <string>
class PP
{public:
int i;
string a;
};
#endif
//main.cpp/////
#include "temph.h"
void main()
{
PP a;
}
为什么会编译错误
--------------------Configuration: temp - Win32 Debug--------------------
Compiling...
main.cpp
e:\c++ program\temp\temp\temph.h(8) : error C2146: syntax error : missing ';' before identifier 'a'
e:\c++ program\temp\temp\temph.h(8) : error C2501: 'string' : missing storage-class or type specifiers
e:\c++ program\temp\temp\temph.h(8) : error C2501: 'a' : missing storage-class or type specifiers
执行 cl.exe 时出错.
temp.exe - 1 error(s), 0 warning(s) 展开
#ifndef _PP_
#define _PP_
#include <string>
class PP
{public:
int i;
string a;
};
#endif
//main.cpp/////
#include "temph.h"
void main()
{
PP a;
}
为什么会编译错误
--------------------Configuration: temp - Win32 Debug--------------------
Compiling...
main.cpp
e:\c++ program\temp\temp\temph.h(8) : error C2146: syntax error : missing ';' before identifier 'a'
e:\c++ program\temp\temp\temph.h(8) : error C2501: 'string' : missing storage-class or type specifiers
e:\c++ program\temp\temp\temph.h(8) : error C2501: 'a' : missing storage-class or type specifiers
执行 cl.exe 时出错.
temp.exe - 1 error(s), 0 warning(s) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询