lundi 3 février 2020

c++ Undefined reference for constructor of class [duplicate]

I have a C++ classes a and b:

// a.cpp

#include <b.h>

a(const std::shared_ptr<node> &n) {
   b objB(n); // ERROR: undefined reference for this line
}

// b.h

b(const std::shared_ptr<node> &n);

// b.c

#include <b.h>
b(const std::shared_ptr<node> &n) {
  cout << n->id << endl;
}

I see compilation failure error: undefined reference to 'b(std::__1::shared_ptr const&)' for the marked line. I ensured the number of arguments are 1 and the includes are correct.

Anything I might be doing wrong?

Aucun commentaire:

Enregistrer un commentaire