0

Getting these two errors:

unresolved external symbol "public: __thiscall RefCount::RefCount(void)" (??0RefCount@@QAE@XZ) referenced in function "public: __thiscall UB_Array<int,char>::Node::Node(int const &)" (??0Node@?$UB_Array@HD@@QAE@ABH@Z)   UB_Array    C:\Users\tasnt\OneDrive\Desktop\C++ 3 Data Structures\UB_Array\UB_Array\main.obj    1       

unresolved external symbol "public: virtual __thiscall RefCount::~RefCount(void)" (??1RefCount@@UAE@XZ) referenced in function __unwindfunclet$??0Node@?$UB_Array@HD@@QAE@ABH@Z$0   UB_Array    C:\Users\tasnt\OneDrive\Desktop\C++ 3 Data Structures\UB_Array\UB_Array\main.obj    1       

I'm in a fundamentals course on Data Structures, our professor has his own created string and pointer class he says we can use for a project we are doing. Following his instructions to set up the libraries we can use I have run into this error.

When I try to add libraries by going to properties -> linker -> input -> (here is where I'm supposed to add library files I believe).

At this point I don't see any .lib files the professor has provided so I'm just looking to be guided on what to do to fix this problem. Have I missed something? I have looked around online and haven't found anything that helps yet.

Alan Birtles
  • 32,622
  • 4
  • 31
  • 60
tmac
  • 1
  • Please search for that error message ("unresolved reference") first. As a new user, also take the [tour] and read [ask]. In particular, your question lacks a [mcve], which you need to extract from your code before even asking here. – Ulrich Eckhardt Feb 12 '20 at 07:46
  • You probably declared but didn't define the constructor and desctructor. Keep in mind that you can use `RefCount() = default;` and `~RefCount() = default` to let the compiler generate a default constructor and destructor. – Lukas-T Feb 12 '20 at 07:59
  • Look where the class `RefCount` is implemented and make sure that you include the object file to the linker parameters. If `RefCount` is in a library, make sure to use the library while linking. Remember the `#include "RefCount.h"`(or similar) only adds the declaration not the implementation of the class in the header file. – harper Feb 12 '20 at 07:59
  • @churill That fixed it. I haven't seen "= default" used before. The RefCount.h and .cpp were in the pointer folder our professor provided. I'm new to actually submitting on stack overflow so I'm not sure if this is the right area to ask this, but I thought the compiler created a default constructor and destructor on its own. – tmac Feb 12 '20 at 08:08
  • @UlrichEckhardt Thanks for pointing me that information, I'll be sure to take the tour and read the "how to ask" section. I didn't add any code because honestly I wasn't sure where exactly the error was happening. I though it had to do with me adding the libraries or directories more than the code. – tmac Feb 12 '20 at 08:11
  • Actually, reducing the current problem to a minimal example is supposed to give you exactly that information. ;) – Ulrich Eckhardt Feb 12 '20 at 08:12

0 Answers0