В моем классе C++ нам было поручено продолжать создавать различные аспекты в этом коде. В настоящее время я получаю 2 ошибки и застрял там, где я не знаю, что я делаю неправильно. Программа берет частный автомобиль или строку для имени и частного целого для ввода в игру, проверяя делимость на 3, 5 и оба 3 & 5. Я должен использовать функцию get и функцию put внутри класса, принимающего входные значения и вывод их. Я по существу понял программу, но она не будет компилироваться, и я действительно не знаю, почему. Вот мой код:Программа, способствующая обучению с использованием классов, частных, общедоступных, конструкторов, функций, целых чисел и строк
#include <iostream>
#include <iomanip>
using namespace std;
using std::istream;
// declare the max size the username input can be
const int MAX = 14;
enum FIZZBUZZ { ABORT = 0, FIZZBUZZ, FIZZ, BUZZ };
class CFizzbuzz // Class definition at global scope
{
// make sure our constructor, destructor, plus member functions are
// all public and available from outside of the class.
public:
CFizzbuzz() {} // Default constructor definition
~CFizzbuzz() {} // Default destructor definition
// function members that are public
// get the user's name and their value from the console and
// store those results into the member variables.
void getFizzbuzz()
{
cout << "Please enter your name: " << endl;
cin >> m_myName;
cout << "Please enter your number for the FizzBuzz game: " << endl;
cin >> m_myNum;
}
// return the user's number type entered
int putFizzBuzz()
{
return m_myNum;
}
char* getName()
{
return m_myName;
}
// logic to check to see if the user's number is 0, fizz, buzz, or fizzbuz
int getRecord(int num)
{
if (num == 0)
{
return ABORT;
}
else if (num % 5 == 0 && num % 3 == 0) // fizzbuzz number
{
return FIZZBUZZ;
}
else if (num % 5 == 0) // buzz number
{
return BUZZ;
}
else if (num % 3 == 0) // fizz number
{
return FIZZ;
}
else
return num;
}
// private data members only available inside the class
private:
int m_myNum;
char m_myName[MAX];
};
int main()
{
CFizzbuzz myClass;
cout << "Welcome to my Fizzbuzz game, you are to guess the location of a "
<< "number which if is divisible by 5 and 3 you will win with "
<< "the output of Fizzbuzz. " << endl;
cout << "Please enter an integer value between 0 and 3 "
<< "representing the row location of the number for the game, "
<< "then press the Enter key: " << endl;
for (;;)
{
myClass.getFizzbuzz();
int num = myClass.putFizzBuzz();
switch (myClass.getRecord(num))
{
case ABORT:
cout << myClass.getName() << "\nThank you for playing\n";
system("PAUSE");
return 0; // exit program
case FIZZ:
cout << "Sorry, " << myClass.getName() << ", number is a Fizz, please try again.\n";
break;
case BUZZ:
cout << "Sorry, " << myClass.getName() << ", number is a Buzz, please try again.\n";
break;
case FIZZBUZZ:
cout << "You win you got FizzBuzz!!!" << endl;
break;
default:
cout << "Sorry, " << myClass.getName() << ", number is a not a Fizz, Buzz, or Fizzbuzz\nPlease try again.\n";
break;
}
}
}
Эти ошибки я получаю:
LNK2019, LNK1120
Можете ли вы предоставить более конкретные ошибки? Укажите строку, описывающую вашу ошибку, вместо _LNK2019_ и _LNK1120_ –
Также вы сказали, что получаете 9 ошибок. Если это так, то каковы ваши другие 7 ошибок? –
Есть только две ошибки. Раньше у меня было 9. Ошибки читаются: неразрешенный внешний символ _WinMain @ 16, указанный в функции «int_cdecl invoke_main (void)» (? Invoke_main @@ YAHXZ) – phoenixCoder