Menu

expected primary-expression before '=' token

jdphenix
2007-09-29
2012-09-26
  • jdphenix

    jdphenix - 2007-09-29

    Hello, I am new to C++ so I'm probably making a silly mistake, but I'm
    having a bit of an issue compiling this program:

    I'm using wxdevcpp 6.10.2.

    main.cpp:

    include "mapinfo.h"

    int main () {
    return 0;
    }

    mapinfo.h:

    // Map Header
    // Contains code necessary to facilitate displaying and moving through the
    // game world.

    include <string>

    include <iostream>

    class GameRoom
    {
    public:
    GameRoom(int roomID, int difficulty = 1, int nConnect = 0, int sConnect = 0, int eConnect = 0, int wConnect = , std::string desc = "");
    void DisplayDesc();
    / Displays the room description to the player. /
    private:
    int m_RoomID;
    int m_MonsterChance;
    int m_Difficulty;
    bool m_NConnection;
    bool m_SConnection;
    bool m_WConnection;
    bool m_EConnection;
    int m_NConnectionID;
    int m_SConnectionID;
    int m_WConnectionID;
    int m_EConnectionID;
    std::string m_Desc;
    int GetNConnectionID();
    int GetSConnectionID();
    int GetWConnectionID();
    int GetEConnectionID();
    / Gets the RoomID's for connections, if any. Returns 0 if there
    * is none.
    /
    bool hasNConnection();
    bool hasSConnection();
    bool hasWConnection();
    bool hasEConnection();
    / Returns true if room has a connect in the indicated direction.
    * Also used to tell the player where they can go.
    /
    int GetRoomID();
    / Gets the RoomID. Used to identify the room and determine what
    * connections it has to other rooms.
    /
    void SetMonsterChance(int difficulty, int mChance);
    / Percentage chance to encounter combat. int difficulty determines monster level /
    };

    GameRoom::GameRoom(int roomID, int difficulty, int nConnect, int sConnect, int eConnect, int wConnect, std::string desc) {
    m_RoomID = roomID;
    m_NConnectionID = nConnect;
    m_SConnectionID = sConnect;
    m_EConnectionID = eConnect;
    m_WConnectionID = wConnect;
    m_Desc = desc;

    if (nConnect)
        m_NConnection = false;
    else
        m_NConnection = true;
    
    if (sConnect)
        m_NConnection = false;
    else
        m_NConnection = true;
    
    if (eConnect)
        m_EConnection = false;
    else
        m_EConnection = true;
    
    if (wConnect)
        m_EConnection = false;
    else
        m_EConnection = true;
    

    }

    void GameRoom::DisplayDesc() {
    std::cout << m_Desc << std::endl;
    }

    int GameRoom::GetRoomID() {
    return m_RoomID;
    }

    int GameRoom::GetNConnectionID() {
    return m_NConnectionID;
    }

    int GameRoom::GetSConnectionID() {
    return m_SConnectionID;
    }

    int GameRoom::GetEConnectionID() {
    return m_EConnectionID;
    }

    int GameRoom::GetWConnectionID() {
    return m_WConnectionID;
    }

    bool GameRoom::hasNConnection() {
    if (m_NConnection)
    return true;
    else
    return false;
    }

    bool GameRoom::hasSConnection() {
    if (m_SConnection)
    return true;
    else
    return false;
    }

    bool GameRoom::hasEConnection() {
    if (m_EConnection)
    return true;
    else
    return false;
    }

    bool GameRoom::hasWConnection() {
    if (m_WConnection)
    return true;
    else
    return false;
    }

    void GameRoom::SetMonsterChance(int difficulty, int mChance) {
    m_Difficulty = difficulty;
    m_MonsterChance = mChance;
    }

    Compile Log:

    Compiler: Default GCC compiler
    Building Makefile: "C:\MyProjects\GameTest-forum\Makefile.win"
    Executing make...
    c:\dev-cpp\bin\mingw32-make.exe -f "C:\MyProjects\GameTest-forum\Makefile.win" all
    c:\dev-cpp\bin\g++.exe -c main.cpp -o Objects/MingW/main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/" -I"C:/Dev-Cpp/include/common/wx/msw" -I"C:/Dev-Cpp/include/common/wx/generic" -I"C:/Dev-Cpp/include/common/wx/fl" -I"C:/Dev-Cpp/include/common/wx/gizmos" -I"C:/Dev-Cpp/include/common/wx/html" -I"C:/Dev-Cpp/include/common/wx/mmedia" -I"C:/Dev-Cpp/include/common/wx/net" -I"C:/Dev-Cpp/include/common/wx/ogl" -I"C:/Dev-Cpp/include/common/wx/plot" -I"C:/Dev-Cpp/include/common/wx/protocol" -I"C:/Dev-Cpp/include/common/wx/stc" -I"C:/Dev-Cpp/include/common/wx/svg" -I"C:/Dev-Cpp/include/common/wx/xml" -I"C:/Dev-Cpp/include/common/wx/xrc" -I"C:/Dev-Cpp/include/common/wx" -I"C:/Dev-Cpp/include/common" -I"C:/Program Files/Microsoft SDKs/Windows/v6.0/Include"

    In file included from main.cpp:1:
    cc1plus.exe: error: expected primary-expression before '=' token

    cc1plus.exe: error: expected primary-expression before '=' token
    cc1plus.exe: error: expected primary-expression before '=' token
    cc1plus.exe: error: expected primary-expression before '=' token
    cc1plus.exe: error: expected primary-expression before '=' token
    cc1plus.exe: error: expected primary-expression before '=' token
    cc1plus.exe: error: expected primary-expression before '=' token
    cc1plus.exe: error: expected primary-expression before '=' token
    cc1plus.exe: error: expected primary-expression before '=' token
    (repeat ad nauseum)

    :2530064: error: expected primary-expression before ')' token
    :2530064: error: expected `,' before ')' token

    c:\dev-cpp\bin\mingw32-make.exe: *** [Objects/MingW/main.o] Error 1

    Execution terminated

     
    • Kurgusov

      Kurgusov - 2007-09-29

      GameRoom(int roomID, int difficulty = 1, int nConnect = 0, int sConnect = 0, int eConnect = 0, int wConnect = , std::string desc = "");

      What is being assigned to int wConnect = ,

      wheres the value?
      or is that a typo?

       
      • jdphenix

        jdphenix - 2007-09-29

        Thank you!! It works as intended now.

        One curiosity: Why did it repeat '"expected primary-expression before '=' token" ad nauseum? There were probably 3 whole pages of it.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.