2016-01-07 2 views
0

Там есть ошибка компиляции в моем коде:ошибка C2143: синтаксическая ошибка: отсутствует ';' до того '*' (не нашли решение)

#include <iostream> 
#include <vector> 
#include "command.h" 

extern std::istream *instream; 
extern std::vector<command> commands; 

Вот command.h заголовочный файл:

#define CMD_RETURN_TYPE_NONE 0 
#define CMD_RETURN_TYPE_STRING 1 
#define CMD_RETURN_TYPE_CHAR 2 
#define CMD_RETURN_TYPE_INT 3 
class command { 
    public: 
     virtual int getReturnType(void); 
     virtual char getOpName(void); 
     virtual void* call(void); 
} 

бросками следующая ошибка компиляции

1>------ Build started: Project: MyFirstCPPApp, Configuration: Debug Win32 ------ 
1>Compiling... 
1>MyFirstCPPApp.cpp 
1>e:\anton\msvc++ projects\myfirstcppapp\myfirstcppapp\MyFirstCPPApp.h(5) : error C2143: syntax error : missing ';' before '*' 
1>e:\anton\msvc++ projects\myfirstcppapp\myfirstcppapp\MyFirstCPPApp.h(5) : error C2377: 'std::istream' : redefinition; typedef cannot be overloaded with any other symbol 
1>  E:\Anton\MSVS2008Express\VC\include\iosfwd(707) : see declaration of 'std::istream' 
1>e:\anton\msvc++ projects\myfirstcppapp\myfirstcppapp\MyFirstCPPApp.h(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>.\MyFirstCPPApp.cpp(4) : error C2039: 'get' : is not a member of 'System::Int32' 
1>  c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : see declaration of 'System::Int32' 
1>.\MyFirstCPPApp.cpp(7) : error C3861: 'callCmd': identifier not found 
1>.\MyFirstCPPApp.cpp(11) : error C2440: '=' : cannot convert from 'std::istream *' to 'int *' 
1>  Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 
1>Build log was saved at "file://e:\Anton\MSVC++ Projects\MyFirstCPPApp\MyFirstCPPApp\Debug\BuildLog.htm" 
1>MyFirstCPPApp - 6 error(s), 0 warning(s) 
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

Я не нашел решение, как его исправить?

+0

Что такое 'command'? 'command.h' соответственно. –

+0

@ πάντα ῥεῖ yeah, command.h, это абстрактный класс –

+0

Пожалуйста, отредактируйте этот вопрос (http://stackoverflow.com/posts/34653404/edit), чтобы добавить такую ​​информацию. –

ответ

2

Отсутствует; после:

команда класса { ... } ;

Все, что находится между закрывающей скобкой и точкой с запятой (обозначение конца строки), будет анализироваться как необязательный список объектов, принадлежащих этому классу.

Таким образом, необходимо добавить точку с запятой после определения класса, чтобы компилятор знал, что все, что приходит после определения этого класса, не является частью списка объектов.

Смежные вопросы