Home c++ Fatal Error LNK2019, Link to Unresolved External Symbol

Fatal Error LNK2019, Link to Unresolved External Symbol

Author

Date

Category

Problem implemented a class to initialize \ sorting, the class logic described in the insteractivetutil.h header file, and defined everything in the InteractiveSortutil.cpp file
When attempting to build errors (LNK2019,1120) arise (LNK2019,1120).
Googling by mistake as it did not help much, please help. It seems like a children’s mistake, and a purely appeared because of my ignorance of the language …

interactiveSort.h


#Pragma OCE
// Describe the necessary files to turn on, in this case, the header for the vector - type cool built-in array
#Include & lt; vector & gt;
#Include & lt; Random & GT;
// Describe the structure of the template class, for the Khanny and sort of vector, as
// initializer values ​​Type of array
Template.
Class sortutil {
  // declare the data structure for the storage of the array
Public: Std :: Vector Basevector;
Public: size_t vectorsize;
     // Structure for describing types of built-in sorting class
Public: Enum SortType
{
  Inserttype.
};
    // Standard designer
Public: Sortutil (Size_t _Vectorsize = 5);
Public: Sortutil ();
Public: ~ Sortutil ();
    // Sort function, incoming parameters - sort type
Public: void sort (sorttype _sorttype);
    // Randomized Initialization
Public: Void Randomizeinit (int lseed, int rseed);
    // Method, for interchanges of values
public: void swap (ATYPE & amp; A, Atype & amp; b);
};

interactiveSort.cpp


#Include "interactiveSortutil.h"
// Determine the class constructor
Template.
Sortutil :: Sortutil (Size_t _Vectorsize) {
  if (_Vectorsize & gt; 0) {
    vectorsize = _Vectorsize;
    // Initialize the vector Asize size
    Baseovector = New Std :: Vector (Vectorsize);
  }
}
Template.
Sortutil :: sortutil () {
  if (_Vectorsize & gt; 0) {
    vectorsize = _Vectorsize;
    // Initialize the vector Asize size
    Baseovector = New Std :: Vector (Vectorsize);
  }
}
Template.
Sortutil :: ~ Sortutil () {
  BaseVector._destroy ();
}
// Determine the method for sorting
Template.
void sortutil :: sort (sorttype _sorttype) {
  Switch (_SortType)
  {
    // If it is sorting inserts, then we struggle the memory under the branch, and perform sorting
  Case (int) SortType :: InsertType: {
    For (int i = 1; i 0 & amp; & amp; BaseVector [j - 1] & gt; basevector [j]; --j) {
      }
    }
    Break;
  }
  Default:
    Break;
  }
}
Template.
Void Sortutil :: Swap (Atype & amp; A, Atype & amp; b) {
  ATYPE TEMP = A;
  a = b;
  b = temp;
}
Template.
Void Sortutil :: RandomizeInit (int lseed, int rseed) {
  For (int i = 0; i 

main.cpp

# include "interactivetututil.h"
#Include.
Using Namespace STD;
INT MAIN () {
  Sortutil b = sortutil (10);
  cin.get ();
  Return 0;
}


Answer 1, Authority 100%

First you have no way it is meaninglessly written template in front of the class, each method, and the type of vector is not declared – you do not specify the template type, it should always be present and Set by corner brackets

template & lt; TypeName T & GT;
Class sortutil {
Public: std :: vector & lt; t & gt; BaseVector;
// ...
Sortutil & lt; int & gt; b;

second you have doubled the default designer, it can cause problems:

public: sortutil (size_t _vectorsize = 5); // After this, you define two constructors at once - the default Sortutil () and the designer with the Sortutil parameter (Size_T)
Public: Sortutil ();

in third directly your problem – compilation has happened successfully, but the collector (Linker) could not find the implementation of the Sortutil constructor (Size_T), it means that your file interactive expect.cpp Not included in the compilation. Add it to the project (as far as I understand you Visual Studio? Then just drag the file to the project)

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions