I am writing a sorting program using a host of different functions as y'all can see from my declarations. However, I keep getting these same errors when I try to compile and run my program they are as follows:
error: use of undeclared identifier 'cout'; did you mean 'count'?
cout << "Hello from main" << endl;
error: reference to overloaded function could not be resolved; did
you mean to call it?
cout << "Hello from main" << endl;
error: use of undeclared identifier 'endl'; did you mean 'end'?
cout << "Hello from main" << endl;
I'm not really sure why I am getting these errors....I thought I included everything I needed to in order to use "cout" and "endl" when I included using namespace std... I have a feeling it has something to do with all my function declarations, but that's just a hunch Any help that y'all can give would be greatly appreciated!!!!!
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
template <typename Comparable>
void insertionSort(vector<Comparable> & a);
template <typename Comparable>
void heapsort(vector<Comparable> & a);
template <typename Comparable>
void percDown(vector<Comparable> & a, int i, int n);
template <typename Comparable>
void mergeSort(vector<Comparable> & a, vector<Comparable> & tmpArray, int left, int right);
template <typename Comparable>
void mergeSort(vector<Comparable> & a);
template <typename Comparable>
void merge(vector<Comparable> & a, vector<Comparable> & tmpArray, int leftPos, int rightPos, int rightEnd);
template <typename Comparable>
void quicksort(vector<Comparable> & a);
template <typename Comparable>
const Comparable & median3(vector<Comparable> & a, int left, int right);
template <typename Comparable>
void quicksort(vector<Comparable> & a, int left, int right);
int main()
{
vector<int> myVector;
cout << "Hello from main" << endl; ///This is where the error is//////
return 0;
}
You have to #include <iostream>
. It is where std::cout
is declared.
You forgot to add the proper library:
#include <iostream>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With