Linker Problem: Undefined reference [SOLVED]
-
Hallo,
ich hatte längere Zeit nichts mit C++ zu tun, und stehe deshalb auf dem Schlauch. In meiner main.cpp bekomme ich immer den Fehler bei "person->doIt();": undefined reference to `Person::doIt()'
main.cpp
#include <string.h> #include <iostream.h> #include "Person.hpp" using namespace std; int main(int argc, char* argv[]) { Person* person= new Person("paul"); person->doIt(); return 0; }Person.cpp
#include <iostream> #include <string> #include "Person.hpp" using namespace std; Person :: Person(string name) { m_name = name; }; void doIt() { }Person.hpp
#ifndef PERSON_HPP_ #define PERSON_HPP_ #include <iostream> #include <string> using namespace std; class Person { private: string m_name; public: Person(string name); void doIt(void); }; #endifEdit: Ich muss natürlich die doIt-Methode als Objekt-Methode deklarieren.
Also mit void Person :: doIt() {...}
Wie schon gesagt - lange nicht mehr damit zu tun gehabt!
LG
-
void Person::DoIt(){} in cpp
scope vergessen.
-
Jo, danke!
Bin eben auch grad noch drauf gekommen^^