Linker Command Failed
Estoy intentando recrear el clásico juego de cartas Siete y medio. Mi problema viene cuando al compilar lo que tengo escrito hasta ahora, XCode me da el siguiente error:
linker command failed with exit code 1 (use -v to see invocation)
Si doy click derecho y pulso "Reveal in log" lo que aparece es esto:
Undefined symbols for architecture x86_64:
"modeA(std::__1::basic_ifstream<char,
std::__1::char_traits<char> >&, int)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Aquí incluyo el código completo. Gracias :)
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
float modeA(ifstream &file, int numCards);
int main(){
srand(time(NULL));
ifstream file;
string fileName;
int numCards;
float sum;
cin >> fileName;
file.open(fileName);
numCards = 3 + rand() % (5 - 3 + 1);
sum = modeA(file, numCards);
cout << sum;
file.close();
return 0;
}
float modeA(ifstream file, int numCards){
int c = 0, card;
float sum, cardValue;
while (c == numCards){
file >> card;
if (card == 10){
cardValue = 0.5;
}
else if (card == 11){
cardValue = 0.5;
}
else if (card == 12){
cardValue = 0.5;
}
else {
cardValue = card;
}
sum += cardValue;
cout << card << endl;
c++;
}
return sum;
}