我正在尝试根据用户输入调用函数。我无法弄清楚我做错了什么。我不断收到此错误
error: no matching function for call to 'sort(std::vector<int, std::allocator<int> >&)'
有人可以告诉我我做错了什么。请彻底解释任何建议,因为我是 C++ 的新手。这是我的代码:
#include <iterator>
#include <algorithm>
#include <vector>
#include <fstream>
#include <iostream>
#include <string>
std::ifstream in("");
std::ofstream out("outputfile.txt");
std::vector<int> numbers;
std::string sortType = "";
std::string file = "";
int main()
{
std::cout << "Which type of sort would you like to perform(sort or mergesort)?\n";
std::cin >> sortType;
std::cout << "Which file would you like to sort?\n";
std::cin >> file;
//Check if file exists
if(!in)
{
std::cout << std::endl << "The File is corrupt or does not exist! ";
return 1;
}
// Read all the ints from in:
copy(std::istream_iterator<int>(in), std::istream_iterator<int>(),
std::back_inserter(numbers));
//check if the file has values
if(numbers.empty())
{
std::cout << std::endl << "The file provided is empty!";
return 1;
} else
{
if(file == "sort")
{
sort(numbers);
}else
{
mergeSort();
}
}
}
void sort(std::vector<int>)
{
// Sort the vector:
sort(numbers.begin(), numbers.end());
unique(numbers.begin(), numbers.end());
// Print the vector with tab separators:
copy(numbers.begin(), numbers.end(),
std::ostream_iterator<int>(std::cout, "\t"));
std::cout << std::endl;
// Write the vector to a text file
copy(numbers.begin(), numbers.end(),
std::ostream_iterator<int>(out, "\t"));
std::cout << std::endl;
}
void mergeSort()
{
//mergesort code..
}