为什么会内存溢出
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;
class String
{
private:
char* str;
int lne;
static int num;
public:
String( char* c );
~String(){cout<<"clear!\n";delete []str;}
friend ostream& operator<<(ostream& os,String &T);
};
String::String( char * c)
{
lne=strlen(c);
str=new char[lne+1];
strcpy(str,c);
}
ostream& operator<<(ostream& os,String& T)
{
os<<T.str<<"\t"<<endl;
return os;
}
void dispaly(String dl)
{
cout<<dl;
}
int main()
{
String l("hello,linux");
String H("hahahahahahahaahahah");
dispaly(l);
dispaly(H);
return 0;
}