我有.cpp和头文件,我得到这个错误,不知道它是什么。
我记得在标题末尾的结尾
和};更接近班级
和#endif
之后的空行无法弄清楚什么是错的。 谢谢你的回答
头文件:
#ifndef playerreceiver_h
#define playerreceiver_h
#include "Client.h"
#include <SFML\Graphics.hpp>
#include <SFML\Network.hpp>
#include "ClientGameFrame.h"
#include "Packets.h"
#include <string>
#include <iostream>
class PlayerReceiver{
public:
PlayerReceiver(int id, std::string name, ClientGameFrame * clientGameFrame);
void recievePackets(sf::Packet &p1);
void draw(sf::RenderWindow & rw);
ClientGameFrame * clientGameFrame;
int id,x, y, hp,energy;
std::string name;
double angle;
Output o;
sf::Sprite sprite;
};
#endif
和cpp文件:
#include "PlayerReceiver.h"
PlayerReceiver::PlayerReceiver(int id, std::string name, ClientGameFrame * clientGameFrame){
this->id=id;
this->name=name;
this->clientGameFrame=clientGameFrame;
x=0;
y=0;
hp=100;
energy=100;
}
void PlayerReceiver::draw(sf::RenderWindow & rw){
rw.draw(sprite);
}
void PlayerReceiver::recievePackets(sf::Packet &p1){
if(checkPacket(p1,output)){
p1>>o;
if(o.id==id){
angle=o.angle;
x=o.x;
y=o.y;
//sprite.setPosition(x, y);
}
}
}
//asda