Hi everyone. I'm fairly new to programming. I have an assignment on classes and I am stuck on calling one particular function.
For some reason the function is not working. Am I calling it wrong?????
OK So HERE IS MAIN.CPP
int main()
{
string fname;
cout << "\t Welcome to Target Helper \n\n";
target t; // create a new target object
char choice = ' ';
while (choice != 'Q')
{
printMenu();
cin >> choice;
// convert choice to to uppercase
choice = toupper(choice);
// ... !
switch (choice)
{
case('N') : t.newGame();
//break;
.................................................. .
My class function (implementation file) is very basic.. I just want to get it working before I add the algorithms.
So I have just done as below... it seems the problem is coming from the main.cpp file though.......??
void target::newGame(char centre, string others)
// pre : none
// post : set centre letter and other letters for a new game of target
{
cout << "Enter centre letter : ";
}
the error message showing is
no matching function for call to 'target::newGame()'
candidates are: void target::newGame(char, std::string)
[build error][puzzle.o] Error 1
Any ideas.. I have been playing around with the PC for over an hour and cant work out what I have done wrong :(
actually I do have another question.... how do i convert chars into a string....?
eg in the below function I have char centre which is easy.. but I have divided string others into chars.. how do I then convert the chars a, b, c, d, e, f, g and h back into one string?
void target::newGame(char centre, string others)
// pre : none
// post : set centre letter and other letters for a new game of target
{
char a, b, c, d, e, f, g, h;
cout << "Enter centre letter : ";
cin >> centre;
cout << "Enter other letters : ";
cin >> a >> b >> c >> d >> e >> f >> g >> h;
centreLetter = centre;