## Recommended Posts

here is what i'm doing:
// ------------ //
// pointclass.h //
// ------------ //
class point_type
{
public:
... constructors and destructors ...
friend std::ostream& operator<<(ostream& outs, const point_type& outstuff);
};

// -------- //
// main.cpp //
// -------- //
#include <iostream>
#include <cstdlib>

int main()
{
point_type stuff;
std::cout << stuff << endl;
return 0;
}

// -------------- //
// pointclass.cpp //
// -------------- //
... all the class definitions ...

std::ostream& operator<<(ostream& outs, const point_type& outstuff)
{
// x, y, and z are floats
outs << "(" << outstuff.x << "," << outstuff.y << "," << outstuff.z ")";
}


i tried compiling that because i was so confident it was right, and devcpp gives me: "ISO C++ forbids declaration of ostream' with no type" "ostream' is neither function nor member function; cannot be declared friend" "expected `;' before '&' token" so i checked my old "problem solving using c++" textbook and it says that is the correct way to do it, then i checked online and this is also how it was done. has the way to do this changed since all those sources were printed or am i doing something wrong that i just can't see? thanks!

##### Share on other sites
Off the top of my head:

Quote:
 friend std::ostream& operator<<(ostream& outs, const point_type& outstuff);

Should be:

friend std::ostream& operator<<(std::ostream& outs, const point_type& outstuff);

I'm assuming you have <iostream> included at the top of pointclass.h?

##### Share on other sites
... doh!

and yet again the simple stupid little things trip me up. i did have that extra "std::" but i forgot to type it in here (should have just copied and pasted), i also forgot to put in the "#include "pointclass.h" " include in the op. however, your second suggestion fixed it. and i thank you very much for helping me correct one of my stupid little brain malfunctions. :)

##### Share on other sites
Quote:
 Original post by supercat1and yet again the simple stupid little things trip me up.

They always are, it happens to everyone.

HTH.