?
=?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?=
Hello.
I am having trouble with namespaces and unresolved externals. The
following three files (memoria.h, memoria.cpp and teste.cpp) illustrate
the problem:
// *************** memoria.h ***************
#include <vector>
namespace mips
{
using std::vector;
using std::size_t;
const unsigned int c_tam_memoria = 65536;
class memoria
{
public:
memoria(const size_t tamanho = c_tam_memoria);
ubyte& operator[](const size_t posicao);
private:
vector<ubyte> m_memoria;
};
}
// ***************end of memoria.h ***************
// *************** memoria.cpp ***************
#include "memoria.h"
namespace mips
{
memoria::memoria(const size_t tamanho)
: m_memoria(tamanho)
{
}
ubyte& memoria:perator[](const size_t posicao)
{
return m_memoria.at(posicao);
}
}
// *************** end of memoria.cpp ***************
// *************** teste.cpp ***************
#include "memoria.h"
int main()
{
using namespace mips;
memoria mem;
mem[100] = 33;
}
// *************** end of teste.cpp ***************
Could anybody tell me what I am missing? I thought I had grasped the
concept of namespaces, but it seems I have not. I would appreciate if
someone could show me where I am wrong.
Thank you very much,
I am having trouble with namespaces and unresolved externals. The
following three files (memoria.h, memoria.cpp and teste.cpp) illustrate
the problem:
// *************** memoria.h ***************
#include <vector>
namespace mips
{
using std::vector;
using std::size_t;
const unsigned int c_tam_memoria = 65536;
class memoria
{
public:
memoria(const size_t tamanho = c_tam_memoria);
ubyte& operator[](const size_t posicao);
private:
vector<ubyte> m_memoria;
};
}
// ***************end of memoria.h ***************
// *************** memoria.cpp ***************
#include "memoria.h"
namespace mips
{
memoria::memoria(const size_t tamanho)
: m_memoria(tamanho)
{
}
ubyte& memoria:perator[](const size_t posicao)
{
return m_memoria.at(posicao);
}
}
// *************** end of memoria.cpp ***************
// *************** teste.cpp ***************
#include "memoria.h"
int main()
{
using namespace mips;
memoria mem;
mem[100] = 33;
}
// *************** end of teste.cpp ***************
Could anybody tell me what I am missing? I thought I had grasped the
concept of namespaces, but it seems I have not. I would appreciate if
someone could show me where I am wrong.
Thank you very much,