It seems that I need to choose one or the other: C++11 or strings.
Player.h
#ifndef PLAYER_H_
#define PLAYER_H_
#include <string>
class Player {
public:
Player();
Player(char symbol);
int promptMove();
virtual ~Player();
bool validMoveFormat(std::string input); // !!!!!!!!
private:
char symbol;
};
#endif /* HW1_PLAYER_H_ */
And Playercpp:
#include "Player.h"
#include <iostream>
using namespace std;
Player::Player() {}
Player::Player(char symbol) {
this->symbol = symbol;
}
Player::~Player() { }
bool validMoveFormat(string move) {
...
...
...
}
int Player::promptMove() {
...
...
...
string move = "hello";
if (!validMoveFormat(move)) { // ERROR!!!!
...
...
}
...
...
}
In promptMove, when I call "validMoveFormat(move)" I get the debilitating error:
undefined reference to `Player::validMoveFormat(std::__cxx11::basic_string, std::allocator >)'
My impression is that this has something to do with GCC 5 versus older versions.
But it is unfathomable to me that such a simple program could not be run without plugging in some esoteric macro to the top of my header files.
Can I just change my compiler? Is there no sensible way to solve this?
Or should I just program without strings?
Aucun commentaire:
Enregistrer un commentaire