Im using c++. Does anyone know how i can fix this?
Undefined symbols for architecture x86_64: "Template::Template(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, int)", referenced from: _main in main.cpp.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
basically writing a merge sort algorithm
main:
int main() {
int SORT_MAX_SIZE = 16;
int userNumInput;
std::string userDataType;
std::cout << "What type of data would you like to enter options: int, string "
"or Dollar objects" << std::endl;
std::cin >> userDataType;
std::cout << "Please enter the number of elements you would like to enter"
<< std::endl;
std::cin >> userNumInput;
if (userNumInput > SORT_MAX_SIZE) {
std::cout << "Please enter the number of elements less then 16"<< std::endl;
std::cin >> userNumInput;
}
Template createTemp = Template(userDataType, userNumInput);
int userData; //todo:how to change this to a different data type
for(int i = 0; i < userNumInput; i++) {
std::cout << "Please enter an element for the spot " + std::to_string(i) <<
std::endl;
std::cin >> userData;
createTemp.userArray[i] = userData;
}
RecurMergeSort(createTemp.userArray, userNumInput);
std::cout << "Sorted Array:" << std::endl;
print(createTemp.userArray, userNumInput);
return 0;
}
template class:
#include "Template.h"
#include "Dollar.h"
Template::Template(const std::string d, int a) {
dataType = d;
numInput = a;
}
void Template::createTemplate() {
//create an array based on the information provided above
if (dataType == "int") {
int userArray[numInput];
} else if (dataType == "Dollar objects") {
Dollar userArray[numInput];
} else if (dataType == "string") {
std::string userArray[numInput];
}
}