#ifndef STRING_H
#define STRING_H
#include<iostream>
using namespace std;
class String
{
private:
char *str;
int len;
static int num_strings;
static const int CINLIM=80;
public:
String(const char *s);
String();
String(const String &);
~String();
int length()const{return len;}
//overloaded operator methods
String & operator=(const String &);
String & operator=(const char *);
char & operator[](int i);
const char & operator[](int i)const;
//overloaded operator friend
friend bool operator<(const String &st,const String &st2);
friend bool operator>(const String &st,const String &st2);
friend bool operator==(const String &st,const String &st2);
friend ostream & operator<<(ostream &os,const String &st);
friend istream & operator>>(istream &is,String & st);
//static function
static int HowMany();
};
#endif // STRING_H
istream & operator>>(istream & is,const String &st)
{
char temp[String::CINLIM];
is.get(temp,String::CINLIM);
if(is)
st=temp;
while(is&&is.get()!='\n')
continue;
return is;
}
錯誤提示

為什么這里面友元函式不能訪問私有成員?
uj5u.com熱心網友回復:
試了一下,在CB下編譯是沒問題的,你用的是什么編譯器?uj5u.com熱心網友回復:
cb啊
uj5u.com熱心網友回復:
暈,今天重試了一下之后發現有沒有問題uj5u.com熱心網友回復:
沒問題
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/74405.html
標籤:基礎類
上一篇:大神哪里錯了
