Undefined reference to deconstructor

I am getting an error when compiling the a code with templated class.
1
2
3
4
5
6
  main.o: In function 'main':
  /home/XXX/XXX/XXX/main.cpp:37: undefined reference to 'sort<int>::~sort()'
  /home/XXX/XXX/XXX/main.cpp:37: undefined reference to 'sort<int>::~sort()'
  collect2: error: ld returned 1 exit status
  Makefile:2: recipe for target 'project' failed
  make: *** [project] Error 1


(The XXX are places holders)
The code around the error in main.cpp looks like this:

1
2
  sort<int> mySort;
  mySort.run(type, lower, upper, increase, file); //THIS IS LINE 37 


If do have the ~sort deconstructor declared in sort.cpp. Why am I still getting an error?
Do you also have it prototyped in a header file? We probably need to see more of your code to diagnose this one.
If do have the ~sort deconstructor declared in sort.cpp

try changing the declartion to a definition i.e. remove the ; and stick { } instead
Last edited on
@gunnerfunner

I have tried both
 
~sort()[]


and

 
~sode()[];


and end up getting the same errors.
then we need to see the full program as previously suggested
I have tried both

~sort()[]

and

~sode()[];


Those don't look like definitions to me. In fact they don't look like any valid syntax at all.

OK, first question - why are you declaring a destructor? Why do you need to write your own destructor? What is it that you want that destructor to do?

Oh, and it's "destructor", not "deconstructor".
MikeyBoy - you've asked the most fundamental question that should have been asked first off, good call
Topic archived. No new replies allowed.