Sep 28, 2013 at 7:29am UTC
#include <iostream>
#include <string.h>
using namespace std;
class GamePlayer
{
char* name;
char* player_id;
int currentLevel;
int topFiveScores[5];
public:
GamePlayer(char* t1, char* t2, int newCurrentLevel, int newTopFiveScores[5], int myTopFiveScore[5])
{
setName(t1);
setplayer_id(t2);
setcurrentLevel(newCurrentLevel);
setTopFiveScores(newTopFiveScores);
}
~ GamePlayer (){
delete [] player_id;
}
void setName(char* t1) {
name = new char [strlen(t1) + 1];
strcpy (name, t1);
}
char* getName(){
return name;
}
void setplayer_id(char* t2) {
player_id = new char [strlen(t2) + 1];
strcpy (player_id, t2);
}
char* getplayer_id(){
return player_id;
}
void setcurrentLevel (int newLevel) {
currentLevel = newLevel;
}
int getcurrentLevel(){
return currentLevel;
}
void setTopFiveScores (int newTopFiveScore[5]){
for (int i=0; i<5; i++) {
topFiveScores[i] = newTopFiveScore[i];
}
}
int* getTopFiveScores(){
return topFiveScores;
}
};
void question2(){
int newTopScores[5] = {2000, 1000, 500, 250, 125};
int myTopScores[5];
GamePlayer name1("Player1", "A123456", 5, newTopScores);
cout << "Name: " << name1.getName() << endl;
cout << "Player ID: " << name1.getplayer_id() << endl;
cout << "Current Level: " << name1.getcurrentLevel() << endl;
cout << "The Top Five Scores: " << name1.getTopFiveScores()[0] << ", "
<< name1.getTopFiveScores()[1] << ", " << name1.getTopFiveScores()[2] << ", "
<< name1.getTopFiveScores()[3] << ", " << name1.getTopFiveScores()[4] << endl;
system ("pause");
}
can anybody help me on this ??
unable to compile out the result.
Sep 28, 2013 at 7:36am UTC
You are trying to constructor a GamePlayer with 4 arguments, but the only constructor you have takes 5.
Sep 28, 2013 at 9:36am UTC
hi zhuge,
how do i resolve this issue ?/
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Users\Ryoma78\Documents\Visual Studio 2010\Projects\TMA 215\Debug\TMA 215.exe : fatal error LNK1120: 1 unresolved externals
Please advice !
thx
Last edited on Sep 28, 2013 at 9:41am UTC
Sep 28, 2013 at 9:53am UTC
It looks like you are trying to build your project as a CRT project. You'll need to go into the properties and make it native C++, or just make a new empty C++ project instead of using the ones they have as examples.