Reputation: 1568
this is a easy question but i cant seem to find the issue
#include <iostream>
namespace utils {
class IntList {
public:
IntList(); // constructor; initialize the list to be empty
void AddToEnd(int k); // add k to the end of the list
void Print(ostream &output); // print the list to output
private:
static const int SIZE = 10; // initial size of the array
int *Items; // Items will point to the dynamically allocated array
int numItems; // number of items currently in the list
int arraySize; // the current size of the array
};
}
here i have defined a class in my header file
but it throws a compiler error saying that it cannot find a reference to ostream
Upvotes: 0
Views: 55
Reputation: 5263
The class from the stl are in the namespace std.
So, unless you are doing using namespace std
, you have to prefix them with std::
. In your case you should be writing std::ostream
.
Upvotes: 5
Reputation: 2699
You are missing the std::
in front of ostream.
You can either :
use the whole namespace before your class definition : using namespace std;
;
mark that you'll be using std::ostream : using namespace std::ostream;
;
or write std::ostream
everywhere you need to use it.
Upvotes: 2