Keep getting "error: use of undeclared identifier 'cout' and error: reference to overloaded function could not be resolved
Asked Answered
P

4

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;
}
Preposition answered 3/4, 2014 at 21:0 Comment(1)
#include <iostream>Isotonic
M
11

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

Macrae answered 3/4, 2014 at 21:2 Comment(0)
D
5

You forgot to add the proper library:

#include <iostream>
Diligence answered 3/4, 2014 at 21:6 Comment(0)
S
4

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

Sanjiv answered 3/4, 2014 at 21:1 Comment(0)
P
2

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

#include <iostream>
using namespace std;

Pompidou answered 23/1, 2019 at 19:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.