packet.h

class OutcomingEnterMap : public PacketFactory { public: int process(Player&); private: MapCharacterBase _MapCharacterBase; }; 

packet_pre_world.cpp

 #include "packet.h" struct MapCharacterBase { /* ... */ }; int OutcomingEnterMap::proces(connection* d) { _MapCharacterBase = MapCharacterBase{/* ... */}; } 

Mistake

 Error C2065 '_MapCharacterBase': undeclared identifier EmulatorTop c:\users\ilya\documents\visual studio 2015\projects\emulatortop\threadevents\packet_pre_world.cpp 142 
  • 1) MapCharacterBase must be predefined in packet.h. 2) Maybe this is a new standard with ++, but = MapCharacterBase{/* ... */}; It seems you can not do that. - nick_n_a
  • one
    you just need to transfer the MapCharacterBase structure definition from packet_pre_world.cpp to packet.h . - KoVadim
  • one
    Accurately determine. It is possible to predetermine only if the pointer to the structure. - nick_n_a

1 answer 1

 #include "packet.h" struct MapCharacterBase { /* ... */ }; 

Turns into

 class OutcomingEnterMap : public PacketFactory { public: int process(Player&); private: MapCharacterBase _MapCharacterBase; // 1 }; struct MapCharacterBase { // 2 /* ... */ }; 

Those. you use the MapCharacterBase before it is declared. The compiler does not understand at point 1 what the MapCharacterBase , since it becomes clear to him only at point 2.