Can Anyone advise me on the problem with the namespace in this code im getting an error.

//Main.
#include "Weapon.h"
#include "Room.h"
#include <iostream>
#include <fstream>
using namespace std;


int main()
{
ifstream myfile;           
        string line;                                                                                       
        myfile.open("BronzeSword.txt");                                                                             
        if (myfile.is_open())                                                                               
        {
                while ( myfile.good() )                                                                     
                {
                        getline (myfile,line);                                                                 
                        cout << line << endl;
                }
                myfile.close();                                                                                    
        }
        else{
                throw("GAME FILE LOADING FAILED!");                                                            
        }
  
	getchar();
	getchar();
};

Could you tell us more about the error in question?

yep, it says error C2143: syntax error : missing ';' before 'using'.

Ah, that helps quite a bit. The problem is very likely to be in the header files, rather than the using directive itself. It is probably from omitting the semicolon after the declaration of the classes. Can you post Weapon.h and Room.h for us?

Ah, that helps quite a bit. The problem is very likely to be in the header files, rather than the using directive itself. It is probably from omitting the semicolon after the declaration of the classes. Can you post Weapon.h and Room.h for us?

Yep sure

//Weapon.h

#ifndef WEAPON_H
#define WEAPON_H
//For use of the String Variable.
#include <string>
#include <iostream>
#include <fstream>
class Weapon
{
public:
	Weapon();//Default Contructor.
    //set functions.
	Weapon(std::string name, int weaponHitPoints);



	void print();
    void save(std::ofstream& outFile);
    void load(std::ifstream& inFile);

private:
	std::string name; 
	int weaponHitPoints;





}



#endif //WEAPON_H
//Room.

#ifndef ROOM_H
#define ROOM_H


#include <iostream>
#include <string>
#include <fstream>
using namespace std;


class Room
{
public:
	Room();//Default Contructor.
    //set functions.
	Room(std::string name, string description, int exit);

	void print();
    void save(std::ofstream& outFile);
    void load(std::ifstream& inFile);

private:
	string name; 
	string description;
	int exit;

	



};
#endif //ROOM_H

As I suspected, the declaration for Weapon is missing the semi-colon at the end (line 30).

I just seen that before you replied lol i hate those errors. Thanks very much.

This question has already been answered. Start a new discussion instead.