hi for some reason when i add a header file and use it with cpp files I always always always
get those errors:
||=== personTry, Debug ===|
obj\Debug\main.o||In function `main':|
C:\Documents and Settings\Administrator\Desktop\cpp\personTry\main.cpp|10|undefined reference to `Person::Person(std::string)'|
C:\Documents and Settings\Administrator\Desktop\cpp\personTry\main.cpp|13|undefined reference to `Person::getIsName()'|
||=== Build finished: 2 errors, 0 warnings ===|
it might be the code so il give you the code also:
main :
#include <iostream>
#include <string>
#include "Person.h"
using namespace std;
int main()
{
Person p("Lebee");
string s = p.getIsName();
cout << s;
return 0;
}
cpp file :
#include <iostream>
#include <string>
#include "Person.h"
using namespace std;
Person::Person()
{
m_name = "david";
}
Person::Person(string p_name)
{
m_name = p_name;
}
string Person::getIsName()
{
return m_name;
}
header file:
#ifndef PERSON_H_INCLUDED
#define PERSON_H_INCLUDED
#include <string>
class Person
{
public:
Person();
Person(std::string p_name);
std::string getIsName();
private:
std::string m_name;
};
#endif // PERSON_H_INCLUDED