Enviado em 27/08/2008 - 18:29h
Saudações!
Estudo C++ e estou com dificuldades para resolver um erro numa função inline
Segue um exemplo:
//Arquivo teste.h
class teste
{
private:
int a;
public:
inline void altera(int x);
}
//Arquivo teste.cpp
#include"teste.h"
inline teste::altera(int x)
{
a = x;
}
//Arquivo exec.cpp
#include"teste.h"
int main()
{
teste var;
var.altera(10);
return 0;
}
Quando compilo e executo gera o seguinte erro:
/caminho/exec.cpp:6: undefined reference to `teste::altera(int)'
Estudo C++ e estou com dificuldades para resolver um erro numa função inline
Segue um exemplo:
//Arquivo teste.h
class teste
{
private:
int a;
public:
inline void altera(int x);
}
//Arquivo teste.cpp
#include"teste.h"
inline teste::altera(int x)
{
a = x;
}
//Arquivo exec.cpp
#include"teste.h"
int main()
{
teste var;
var.altera(10);
return 0;
}
Quando compilo e executo gera o seguinte erro:
/caminho/exec.cpp:6: undefined reference to `teste::altera(int)'