6

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:

  1. error: use of undeclared identifier 'cout'; did you mean 'count'?

    cout << "Hello from main" << endl;

  2. error: reference to overloaded function could not be resolved; did you mean to call it?

    cout << "Hello from main" << endl;

  3. 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;
}
Dan
  • 872
  • 10
  • 24
Jok3r
  • 163
  • 3
  • 4
  • 8

4 Answers4

11

You have to #include <iostream>. It is where std::cout is declared.

4pie0
  • 29,204
  • 9
  • 82
  • 118
5

You forgot to add the proper library:

#include <iostream>
user2076694
  • 806
  • 1
  • 6
  • 10
4

You should add #include <iostream> in the beginning of your program

Mathias711
  • 6,568
  • 4
  • 41
  • 58
2

Check for these lines in the beginning of your c++ program.

#include <iostream>
using namespace std;

Prateek099
  • 549
  • 1
  • 5
  • 15