hi!
I have a class same as below:

class sample{
friend ostream& operator<<(ostream &ostr,sample p);
private:
//:
//:
public:
//:
//:
};
//---------------------------------------------------
ostream& operator<<(ostream &ostr,sample p){
           //:
           //:
        return ostr;
}

While the compiler get to line(***) make failed with this error report:
type name expected! ( but I define the "sample" type!!)
:?: do you know ---> why this error happened??
tnx.

>do you know ---> why this error happened??
Not with your incredibly sparse example. However, once I include <iosfwd> and do a using std::ostream, it compiles fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.