Reputation: 819
i have a bit of a problem but not sure what it is.
header.h:
#ifndef CONTINENT_H_INCLUDED
#define CONTINENT_H_INCLUDED
#include <string>
#include <vector>
class Territory;
class Player;
namespace Sep
{
//----------------------------------------------------------------------------
// Continent class
// class consist of many territories
//
class Continent
{
private:
public:
//--------------------------------------------------------------------------
// Constructor
//
Continent();
//--------------------------------------------------------------------------
// Copy Constructor
// Makes a copy of another Continent Object.
// @param original Original to copy.
//
Continent(const Continent& original);
//--------------------------------------------------------------------------
// Assignment Operator
// Used to assign one Continent to another
// @param original Original with values to copy.
//
Continent& operator= (Continent const& original);
//--------------------------------------------------------------------------
// Destructor
//
INCLUDED
virtual ~Continent();
//--------------------------------------------------------------------------
// Constructor to forward attributes
//
Continent(std::string name, std::vector<Territory*> territories);
};
}
#endif // CONTINENT_H_INCLUDED
.cpp:
#include "Continent.h"
//------------------------------------------------------------------------------
Continent::Continent()
{
}
//------------------------------------------------------------------------------
Continent::Continent(std::string name, std::vector<Territory*> territories) :
name_(name), territories_(territories)
{
}
//------------------------------------------------------------------------------
Continent::~Continent()
{
}
Sorry for putting in the whole code but i dont want to take any risks. ERROR: g++ -Wall -g -c -o Continent.o Continent.cpp -MMD -MF ./Continent.o.d Continent.cpp:13:1: error: ‘Continent’ does not name a type
from that i got that it is a problem between the header define and the .cpp but whats the problem there i cant see it.
thx for any help :)
Upvotes: 0
Views: 169
Reputation: 82535
You declared Continent
in the namespace Sep
in your header, but in your .cpp, you use Continent
in global scope, where it is not defined.
You should either add using namespace Sep;
after the #include
in your .cpp, wrap all the definitions in a namespace Sep { ... }
, or put Sep::
in front of each use of Continent
.
Upvotes: 4