Home > Back-end >  C function cannot access private members
C function cannot access private members

Time:09-25

 
# # ifndef STRING_H
# define STRING_H
# include

using namespace std;
The class String
{
Private:
Char * STR;
int len;
Static int num_strings;
The static const int CINLIM=80;

Public:
String (const char * s);
String ();
String (const String & amp;);
~ the String ();
Const int length () {return len. }

//overloaded operator the methods
String & amp; Operator=(const String & amp;);
String & amp; Operator=(const char *);
Char & amp; Operator [] (int I);
Const char & amp; Operator [] (int I) const;

//overloaded operator friend
Friend bool operator<(const String & amp; St, const String & amp; St2);
Friend bool operator> (const String & amp; St, const String & amp; St2);
Friend Boolean operator==(const String & amp; St, const String & amp; St2);
Friend ostream & amp; Operator<(ostream & amp; OS, const String & amp; St);
Friend cost & amp; Operator> (cost & amp; Is the String & amp; St);
//the static function
Static int HowMany ();
};
# endif//STRING_H

Cost & amp; Operator> (cost & amp; The const String & amp; St)
{
Char \ [String: : CINLIM];
Is the get (temp, String: : CINLIM);
If (is)
St=temp;
While (is& & Is the get ()! )
='\ n'continue;
The return is;
}


Error


Why is this a friend function cannot access private members in it?

CodePudding user response:

Tried to compile under the CB is no problem, what do you use the compiler?

CodePudding user response:

reference 1st floor dataxdata response:
try and compile under the CB is no problem, what do you use the compiler?

Cb:

CodePudding user response:

Dizzy, try again after the found today if you have any questions

CodePudding user response:

No problem
  • Related