Hello. I am creating a bool function that returns whether an integer in a vector is greater than the second integer, but I don't know how to compare them.
You have included the "string" header file, but never use a string.
You do use a vector, but need to include the header file for vectors.
Do yo want to sort the vector or compare two numbers of the vector? You should consider changing the name to something that better describes what the function does.
#include <iostream>
#include <string>
#include <vector> // <--- Added. Need to include this header file to use vectors.
//using namespace std; // <--- Best not to use.
bool checkNumbers(int num1, int num2);
int main()
{
std::vector<int> numbers{ 2, 20, 15, 20, 5 };
for (size_t lc = 0; lc < numbers.size()-1; lc++)
{
if (checkNumbers(numbers[lc], numbers[lc + 1]))
std::cout << "\n First number greater than second\n" << std::endl;
else
std::cout << "\n First number less than second\n" << std::endl;
}
std::cin.get();
return 0;
}
bool checkNumbers(int num1, int num2)
{
return num1 > num2; // how do I compare the second number?
}