클래스와 분리 된 기능을 사용하여 행맨 게임을 만들어야합니다. 더 쉽게 할 수있는 방법은 각 왼쪽 라이브에 대해 기능을 만드는 것이었지만 전화 할 때 인쇄하지 않습니다 ... 아마 어느 누구와도이 문제를 해결할 수 있습니다. 감사합니다.교수형 교수형 게임 클래스를 사용하면 작동하지 않을 수 있습니다
This is the main
// TheHangmanGame.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "DrawHangman.h"
#include <iostream>
#include <string>
#include <ctime>
using namespace std;
int main()
{
cout << "WHY wont u WORK!!!! \n" ;
cout << "asdf" << &DrawHangman::setDrawMan0 << "\n" ;
cout << "work \n";
system("PAUSE");
return 0;
}
// ----------------------------------------- ---
//header file
#ifndef DRAWHANGMAN_H
#define DRAWHANGMAN_H
#include "stdafx.h"
#include <string>
using namespace std;
class DrawHangman
{
public:
DrawHangman(char);
void setDrawMan0(char);
int getDrawMan0();
void setDrawMan1(char);
int getDrawMan1();
void setDrawMan2(char);
int getDrawMan2();
void setDrawMan3(char);
int getDrawMan3();
void setDrawMan4(char);
int getDrawMan4();
void setDrawMan5(char);
int getDrawMan5();
void setDrawMan6(char);
int getDrawMan6();
};
#endif
// -------------------------------
//cpp file
#include "stdafx.h"
#include "DrawHangman.h"
#include <iostream>
using namespace std;
DrawHangman::DrawHangman(char)
{
}
void DrawHangman::setDrawMan0(char)
{
using namespace std;
cout << "_______" << endl;
cout << "| |" << endl;
cout << "|" << endl;
cout << "|" << endl;
cout << "|" << endl;
cout << "|" << endl;
}
int DrawHangman::getDrawMan0()
{
return 1;
}
void DrawHangman::setDrawMan1(char)
{
cout << "_______" << endl;
cout << "| |" << endl;
cout << "| o" << endl;
cout << "|" << endl;
cout << "|" << endl;
cout << "|" << endl;
}
void DrawHangman::setDrawMan2(char)
{
cout << "_______" << endl;
cout << "| |" << endl;
cout << "| o" << endl;
cout << "| /" << endl;
cout << "|" << endl;
cout << "|" << endl;
}
void DrawHangman::setDrawMan3(char)
{
cout << "_______" << endl;
cout << "| |" << endl;
cout << "| o" << endl;
cout << "| /|" << endl;
cout << "|" << endl;
cout << "|" << endl;
}
void DrawHangman::setDrawMan4(char)
{
cout << "_______" << endl;
cout << "| |" << endl;
cout << "| o" << endl;
cout << "| /|\\" << endl;
cout << "|" << endl;
cout << "|" << endl;
}
void DrawHangman::setDrawMan5(char)
{
cout << "_______" << endl;
cout << "| |" << endl;
cout << "| o" << endl;
cout << "| /|\\" << endl;
cout << "| /" << endl;
cout << "|" << endl;
}
void DrawHangman::setDrawMan6(char)
{
cout << "_______" << endl;
cout << "| |" << endl;
cout << "| o" << endl;
cout << "| /|\\" << endl;
cout << "| /\\" << endl;
cout << "|" << endl;
}
''Cout << "asdf"<< & DrawHangman :: setDrawMan0 << "이라고 생각하지 않습니다. \ n"; "당신이 생각하는대로합니다. – Borgleader
k 내가 바꿨지 만 리턴 1을 넣었으므로 1을 반환합니다. 어떻게 쓰여지는지 프린트 할 수 있나요? –
OOP 기본 사항을 검토해야합니다. a) 실제로 함수를 호출하지 않는다. (힌트 :'()'가 없으며 처음에는'&'를 사용하지 말아야한다.) b)'DrawHangman ::'도 틀렸다. 왜 그런지 알아 내야합니다. – Borgleader