Kody Puebla Kody Puebla - 7 days ago 5
C++ Question

compiler errors with function declaration c++

I get the following compiler error when I try to build my program:

main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall OddsCalculator::is_straight_flush(__int64)" (?is_straight_flush@OddsCalculator@@QAE_N_J@Z) referenced in function _main


I figured this was an issue of scope since I did not put "OddsCalculator::" in front of the function. However, when I go to fix that, I get this error:

odds_calculator.cpp(568): error C2589: 'bool': illegal token on right side of '::'


I haven't been able to find anything online that matches this error, so I'm not sure what's wrong.

This is main.cpp:

#include <iostream>
#include <string>

#include "odds_calculator.h"

int main() {
OddsCalculator calc;

// hand: KH QH table: AH JH TH 2D 6S
std::cout << calc.is_straight_flush(0x7c201000) << std::endl;
}


This is what the function looks like in odds_calculator.h:

#ifndef ODDS_CALCULATOR_H
#define ODDS_CALCULATOR_H

#include <string>
#include <iostream>
#include <fstream>
#include <sstream>

class OddsCalculator {
public:
// other functions
bool is_straight_flush(long long in_play);
};

#endif


This is what the function looks like in odds_calculator.cpp:

#include "odds_calculator.h"

OddsCalculator::bool is_straight_flush(long long in_play) {
// code
}


I'm using VS2015 x86 Native Tools Command Prompt, and I use the command
cl /EHsc main.cpp odds_calculator.cpp
to compile. Any ideas?

Answer
bool OddsCalculator::is_straight_flush(long long in_play) {
    // code
}
Comments