I created a program that uses a friend function to access the private member variabls, it runs perfectly in Shedblood Dev-C++, but when i use Microsoft Visual C++ 6 to compile it, the compiler tell me that "the function is not allowed to access private members." Does this mean that Visual C++ doesn't support friend function?
The following is part of the code:
class String
{
public:
String ();
~String ();
//member functions
friend ostream & operator << (ostream &, String &);
private:
char * m_str;
};
int main ()
{
//........
}
//implementation of member functions
ostream & operator << (ostream & os, String & str)
{
os << str.m_str;
return os;
}