[C++] "Multiple types in one declaration" po dodaniu Windows.h
Ostatnio zmodyfikowano 2013-12-15 12:17
Kentox Temat założony przez niniejszego użytkownika |
[C++] "Multiple types in one declaration" po dodaniu Windows.h » 2013-12-11 20:59:12 Po skompilowaniu mojego projektu dołaczając windows.h kompilator podaje następujące błędy. E:\Dane\C++\Risk\main.cpp:10:10: error: multiple types in one declaration E:\Dane\C++\Risk\main.cpp:10:10: error: declaration does not declare anything [-fpermissive] E:\Dane\C++\Risk\main.cpp:10:10: error: expected primary-expression before 'struct' E:\Dane\C++\Risk\main.cpp:10:10: error: expected ';' before 'struct' E:\Dane\C++\Risk\main.cpp:11:11: error: expected primary-expression before 'struct' E:\Dane\C++\Risk\main.cpp:11:11: error: expected ')' before 'struct' E:\Dane\C++\Risk\main.cpp:11:11: error: expected primary-expression before 'struct' E:\Dane\C++\Risk\main.cpp:11:11: error: expected ';' before 'struct' Wystarczy jednak usunąć #include <Windows.h> z pliku Helper.h aby błędy zniknęły. Oto pliki: Helper.h: #ifndef HELPER_H_INCLUDED #define HELPER_H_INCLUDED #include <Windows.h> #include <vector> #include <string>
enum Color { blank, red, green, blue, yellow, purple, brown, orange, white };
struct Region { int index; char Name[ 30 ]; int Neighbours[ 10 ]; int Army; Color Owner; };
class Map { public: Map( const char * FileName ); Map( const char * FileName, int NumberOfAi, int NumberOfHuman ); int Initialize( int NumberOfAi, int NumberOfHuman ); Region * OwnedTerritories( Color owner ); Region * NeighbourTerritories( int MyIndex ); Region * NeighbourTerritories( Region MyTerritory ); void SetRegion( Region NewRegion, int TargetIndex ); void AddReinforce( int NewUnits, int TargetIndex ); int CheckCountryTroops( Color Owner ); int AmountOfTerritories( Color Owner ); protected: Region Graph[ 40 ]; };
#endif
Com.h: class Comm { public: bool GameOn; int StartMenu(); int SetAi(); int SetHuman(); const char * SetMap(); int BasicMenu(); void MoveOut(); const char * ChooseMap(); enum StartOptions { play, exit }; }; Com.cpp: #include <iostream> #include "Helper.h" #include "Com.h"
int Comm::StartMenu() { std::cout << "THE" << std::endl; std::cout << "RISK" << std::endl; std::cout << "[0]GRAJ" << std::endl; std::cout << "[1]WYJDZ" << std::endl; std::cout << std::endl; int choice; std::cin >> choice; return choice; }
int Comm::SetAi() { std::cout << "Set number of AI" << std::endl; int AI; std::cin >> AI; return AI; }
int Comm::SetHuman() { std::cout << "Set number of Humans" << std::endl; int Humans; std::cin >> Humans; return Humans; } const char * Comm::SetMap() { }
Engine.h #ifndef ENGINE_H_INCLUDED #define ENGINE_H_INCLUDED #define AI 0 #define HUMAN 1 #include "Helper.h" #include "Com.h"
class Engine { public: Engine(); Region Attack( int SourceIndex, int TargetIndex ); Region Reinforce( int TargetIndex ); Region Transfer( int SourceIndex, int TargetIndex ); private: Map & G; Comm & UI; bool Players[ 9 ]; };
#endif
Plik Engine.cpp jest pusty, bo jeszcze nie zdefiniowałem żadnych funkcji składowych i main.cpp #include "Com.h" #include "Engine.h"
using namespace std;
int main() { Comm interface; while( interface.StartMenu() == Comm::play ) { } return 0; }
|
|
pekfos |
» 2013-12-15 12:17:01 |
|
« 1 » |