istream ostream problem

header
1
2
3
4
5
6
7
	// Print to an output stream. This is a friend function,
	// so it is not a member of StrLib.
	// Overload << as a friend function
	friend ostream &operator<<(ostream &, const StrLib &);
	// Read from an input stream.
	// Overload >> as a friend function here.
	friend istream &operator>>(istream &, StrLib &);


StrLib.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Print to an output stream. This is a friend function,
// so it is not a member of StrLib.
// Overload << as a friend function
ostream &operator<<(ostream &out, const StrLib &str)
{
	int size = str.length();
	for (int i = 0; i < size; i++)
		out << str.cstr[i] << endl;
	return out;	
}

// Read from an input stream.
// Overload >> as a friend function here.
istream &operator>>(istream &input, StrLib &str)
{
	for (int i = 0; i < str.length(); i++)
		input >> str.cstr[i];

	return input; // enables cin >> x >> y; 
}// end function 


I am having an issue with my code. We are overloading the ostream and istream operator. Pretty much we have a class called StrLib and we are creating objects that only has a private data member that is also a pointer named
char *cstr;
we are trying to output for ostream and whenever we compile we are receiving over 70 errors.
The pointer is pointing to a array of characters and we are to output the array of characters as a string. or something. Can anyone point in the right direction and help would be greatly appreciated! thank you!
What's the first error?
1. error c2143; syntax error: missing ';' before '&'
this error is referring to friend ostream about line 4 that i posted previous for header
Topic archived. No new replies allowed.