Hi Everyone,

Sorry to be such a noob, but I am hopping you guys can help me out a bit.
I keep on getting this error "expected an expression error" in the first open curly brace of the 'void playerCMD();' function and also in case 1. I am using the Vusial Microsoft IDE.

//calling all files/////////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "functionsDec.h"
#include "classes.h"

/////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////   Functions /////////////////////////////////////////////////
void playerCMD();
{
    cout << "Choose a command:\n"
        << "1: Attack\n"
        << "2: Use potion\n"
        << "0: Skip turn/defend\n\n";

    int choice;cout << "choice: ";
    cin >> choice;
    bool pass = true;


    do switch (choice)
    {
        case 0:
            {
                cout << "You are defending\n";
                zidane.beAttacked;
                pass==true;
                break;
            }
        case 1:
            {
                cout << "You attacked Kuja\n";
                zidane.attack();
                pass==true;
                break;
            }
        case 2:
            {
                cout << "You use a potion\n";
                zidane.heal(20);
                pass==true;
                break;
            }
        default :
            {
                cout << "You made an illegal choice\n";
                pass==false;
            }
    } while (!pass)

    return 0;
}

You have a semi-colon at the end of the declaraion line. Remove that. Ie where you have

void playerCMD();
{
.
.
.
}

You should have

void playerCMD()
{
.
.
.
}

There should't be a semi-colon(;) after void playerCMD() here in your program, in fact, if you give a declaration of a function at the beginning of the program, the ";" is needed, but when it comes to the definition, the";" is not supposed to exsit.

Take a look at the example:

#include<iostream>

void playerCMD();
void takeCMD();


void playerCMD()
{
  statements;
}

void takeCMD()
{
  statements;
{

void main()
{
  statements;
}

and if is a void type, you can't use 'return 0;'. because the void type don't return any value;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.