c++ - Undefined reference error at class instantiation -


this main.cpp. program starts here , have problem:

i 2 errors:

undefined reference `bankcontroller::bankcontroller(transactionrepository)* @ line 23

and

undefined reference `transactionfilerepository::transactionfilerepository(std::string) @ line 19

for both of them, type c/c++ problem, resource main.cpp

#include "bankgui.h" #include "controller/bankcontroller.h" #include "repository/transactionfilerepository.h" #include "repository/transactionmemoryrepository.h" #include "repository/transactionrepository.h"  #include <qtgui> #include <qapplication> #include <string> #include <iostream> using namespace std;  int main(int argc, char *argv[]){    string path = "datastorage/database.txt";    //instantiate main data repository   transactionrepository* maindatabase;   maindatabase = new transactionfilerepository(path); // <-- error here    //instantiate main controller   bankcontroller* maincontroller;   maincontroller = new bankcontroller(maindatabase); // <-- same error here    //starts gui   qapplication app(argc, argv);   bankgui* mainwidget;   mainwidget = new bankgui(maincontroller);   mainwidget->show();    return app.exec(); } 

i have 3 classes:

  • a virtual transactionrepository

  • one class implements above transactionmemoryrepository

  • one class inherits above transactionmemoryrepository transactionfilerepository

i've been searching several hours on google solutions try doesn't rid of errors.

i should mention c++ qt project working on. had add project properties include paths things work.

all files #included exist.

this linker error. means parts (the different .cpp files) of program compiled linker can't figure out how put them together.

just have use #includes (of .h files) tell compiler function defined in different file need give parameters linker use compiled files (those created .cpp) find functions

the compilation process described in answer question.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -