전매 체 게임을 프로그래밍하고 있습니다. 그리고이 경우 플레이어가 그룹별로 소유 한 속성을 정렬하여 좋은 깨끗한 결과물을 만들기위한 정렬 기능을 정말 좋아합니다. 모든삭제 된 함수 연산자를 참조하려고하는 컴파일러 오류 C2280 =
먼저 여기에 플레이어는 이러한 속성의 목록을 소유하고, 이제 내 재산 분류기 기능
bool propertySort(Property a, Property b) { return a.getGroup() < b.getGroup(); }
입니다.
#pragma once
#include <string>
#include <vector>
#include "Dice.h"
#include "Property.h"
class Player
{
public:
...
private:
int curMoney{ 1500 };
int curLocation{ 0 };
int playerNum{ 0 };
std::string name;
std::vector<Property> ownedProperties{};
int curDiceRoll;
};
보시다시피 속성은 0 속성으로 초기화되었습니다.
메인에있는 내 속성 분류기에서 플레이어가 볼 수 있도록 보드에 속성을 표시 할 곳은 분류기 기능이 지속적으로 오류 C2280을 계속 제공합니다. 나는 정확하게이 정렬 함수가이 오류를 던지는 것을 알고있다. 왜냐하면 내가 프로그램을 잘 수행하는 정렬 줄을 주석 처리하기 때문이다. 내가 초보 프로그래머이기 때문에 내가 무지하다는 것은 분명하다. 누구라도 그것이 무엇인지에 대한 통찰력을 제공 할 수 있다면, 고마워요!
void viewProperties(Player& p)
{
string prompt = "Select a player to view their properties";
vector<string> playerNames{};
for (Player p : players)
{
playerNames.push_back(p.getName());
}
Menu propertiesMenuSelection{ prompt, playerNames };
vector<Property> propertiesOfSelectedPlayer = players[propertiesMenuSelection.getChoice()].getOwnedProperties();
sort(propertiesOfSelectedPlayer.begin(), propertiesOfSelectedPlayer.end(), propertySort);
system("CLS");
는 경우이 여기에 도움이 속성 클래스를
#pragma once
#include "Space.h"
#include <array>
#include <vector>
extern std::vector<Player> players;
class Property : public Space
{
public:
Property(std::string name, std::vector<int> values);
~Property();
void run(Player&) override;
std::vector<std::string> boardOut() const override;
std::string getName() const override;
...
private:
std::string name;
int group;
int price;
int buildingCost;
int buildings;
Player* ownerPtr = nullptr;
std::array <int, 6> rent;
const std::array <std::string, 10> groups{ "Brown", "Light Blue", "Pink", "Orange", "Red", "Yellow", "Green", "Dark Blue", "Railroad", "Utility" };
};
있어 여기에 간단한 요청에 따라 공간 클래스입니다.
#pragma once
#include <string>
#include <vector>
class Player;
class Space
{
public:
virtual void run(Player&) = 0;
virtual std::string getName() const = 0;
virtual std::vector<std::string> boardOut() const = 0;
};
어떤 부분 할당이 아니다. 귀하의 게시물에'스페이스'를 포함시킬 수 있습니까? –
'give me error C2280' - 런타임 오류가 아니라 컴파일러 오류이므로 질문 제목에서 알 수 있듯이 오류가 발생하지 않습니다. – PaulMcKenzie
'const std :: array' -이 멤버 변수가 복사를 사용할 수없는 이유 일 수 있습니다. – PaulMcKenzie