怎么在.h文件中使用前置申明,本人想使用std:string前置申明,删除#include
如何在.h文件中使用前置申明,本人想使用std::string前置申明,删除#include<string>
#ifndef ROBOT_ROBOT_H_
#define ROBOT_ROBOT_H_
#include <string>
#define _ROBOT_BEGIN_ namespace robot_namespace {
#define _ROBOT_END_ }
_ROBOT_BEGIN_
class robot
{
public:
robot();
virtual ~robot();
int run(const std::string &_command);
};
_ROBOT_END_
#endif
------解决方案--------------------
string是个typedef,不是class
------解决方案--------------------
#ifndef ROBOT_ROBOT_H_
#define ROBOT_ROBOT_H_
#include <string>
#define _ROBOT_BEGIN_ namespace robot_namespace {
#define _ROBOT_END_ }
_ROBOT_BEGIN_
class robot
{
public:
robot();
virtual ~robot();
int run(const std::string &_command);
};
_ROBOT_END_
#endif
------解决方案--------------------
string是个typedef,不是class
------解决方案--------------------