#include
#include
#include
// class definition
class String
{
private:
char*buf;
public:
//constractors
String();
String(const char*s)
{
buf=new char[30];
strcpy(buf,s);
}
// display
void display()
{
cout<
int length()const
{
return strlen(buf);
}
void operator=(const String &other);
};
void String::operator=(const String &other)
{
int length;
length=other.length();
delete buf;
buf=new char [length+1];
strcpy(buf,other.buf);
}
main()
{
String myString("=s2");
cout<<"s1+";
myString.display();
cout<<"\n";
String yourString("s3=");
cout<<"\n";
yourString=myString;
cout<<"s3=s1+";
yourString.display();
cout<<"\n";
system("pause");
}
......Indian Songs.......
Wednesday, February 10, 2010
CS 201 Ass Solution
Posted by Alisha Naaz at 10:43 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment