내 C++ 클래스에서는이 코드에 다른 측면을 계속 작성해야합니다. 현재 2 개의 오류가 발생하고 내가 뭘 잘못하고 있는지 알지 못하는 곳에 갇혀 있습니다. 이 프로그램은 이름과 개인 정수를위한 개인용 자동차 또는 문자열을 3, 5 및 둘 모두로 게임 검사에 입력하도록합니다. 3 & 5. 클래스 내에서 get 함수와 put 함수를 사용합니다. 입력 값을 출력합니다. 필자는 본질적으로 프로그램을 알아 냈지만 컴파일되지는 않을 것이며 그 이유는 확실하지 않습니다. 여기 내 코드입니다 :클래스, private, public, 생성자, 함수, 정수 및 문자열을 사용하여 학습 추가 학습
#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, 당신이 의견에 언급 된 오류 (Unresolved external symbol [email protected]
) 나는 당신이를 만든 말하고 싶지만 바탕으로 LNK1120
더 구체적인 오류를 제공해 줄 수 있습니까? _LNK2019_ 및 _LNK1120_ –
대신 오류를 설명하는 줄을 제공하십시오. 또한 9 개의 오류가 발생했다고합니다. 그렇다면 다른 7 가지 오류는 무엇입니까? –
두 가지 오류 만 있습니다. 나는 이전에 9 명을 가지고 있었다. 읽은 오류 : 확인되지 않은 외부 기호 _WinMain @ 16 "int_cdecl invoke_main (void)"(? invoke_main @@ YAHXZ) – phoenixCoder