M
milicic.marko
I have very simple problem to solve.
I have three files
--
first is: main.cpp
--
#include "osoba.h"
int main (void)
{
osoba o;
o.stampaj();
}
--
Second is "osoba.cpp"
--
#include "osoba.h"
void
osoba::stampaj()
{
std::cout<<"zdravo";
}
osoba:soba()
{
}
osoba::~osoba()
{
}
--
Third is: "osoba.h"
--
#ifndef OSOBA_H
#define OSOBA_H
#include <string>
class osoba
{
public:
osoba();
~osoba();
void stampaj();
private:
std::string _ime;
std::string _nadimak;
};
#endif
When I complile, I got this error:
bash-2.05b$ g++ -o main main.cpp
/tmp/ccLgxIrl.o(.text+0x19): In function `main':
: undefined reference to `osoba:soba[in-charge]()'
/tmp/ccLgxIrl.o(.text+0x28): In function `main':
: undefined reference to `osoba::stampaj()'
/tmp/ccLgxIrl.o(.text+0x3f): In function `main':
: undefined reference to `osoba::~osoba [in-charge]()'
/tmp/ccLgxIrl.o(.text+0x5c): In function `main':
: undefined reference to `osoba::~osoba [in-charge]()'
collect2: ld returned 1 exit status
bash-2.05b$
How should I solve this problem?
I have three files
--
first is: main.cpp
--
#include "osoba.h"
int main (void)
{
osoba o;
o.stampaj();
}
--
Second is "osoba.cpp"
--
#include "osoba.h"
void
osoba::stampaj()
{
std::cout<<"zdravo";
}
osoba:soba()
{
}
osoba::~osoba()
{
}
--
Third is: "osoba.h"
--
#ifndef OSOBA_H
#define OSOBA_H
#include <string>
class osoba
{
public:
osoba();
~osoba();
void stampaj();
private:
std::string _ime;
std::string _nadimak;
};
#endif
When I complile, I got this error:
bash-2.05b$ g++ -o main main.cpp
/tmp/ccLgxIrl.o(.text+0x19): In function `main':
: undefined reference to `osoba:soba[in-charge]()'
/tmp/ccLgxIrl.o(.text+0x28): In function `main':
: undefined reference to `osoba::stampaj()'
/tmp/ccLgxIrl.o(.text+0x3f): In function `main':
: undefined reference to `osoba::~osoba [in-charge]()'
/tmp/ccLgxIrl.o(.text+0x5c): In function `main':
: undefined reference to `osoba::~osoba [in-charge]()'
collect2: ld returned 1 exit status
bash-2.05b$
How should I solve this problem?