Docsity

Creating a Custom String Class: Mystring, Exercises of Advanced Computer Programming

Toggle sidebar
bg1
You need to make the class of Mystring which have one char* & integer size, It take
the size of string from user & than Enter the string from the user.
1. Class Mystring
2. {
3. Char* Str;
4. Int Size;
5. };
Overload the following operator for the class Mystring:
“>>”: take the input of object of Mystring, i.e. 1st string size & than string
Main()
{
Mystring obj;
Cin>>obj;
}
“<<”: Show the output of object of Mystring, i.e. 1st string size & than string
Main()
{
Eneter the Size of String: 25
Enter String: Mid-Exam was so easy
Your output is:
The Size of String Al located: 25
The Original Size of String: 20
String: Mid-Exam was so easy
docsity.com
pf3
pf4

Partial preview of the text

Download Creating a Custom String Class: Mystring and more Exercises Advanced Computer Programming in PDF only on Docsity!

You need to make the class of Mystring which have one char* & integer size , It take

the size of string from user & than Enter the string from the user.

  1. Class Mystring
  2. {
  3. Char* Str;
  4. Int Size;
  5. };

Overload the following operator for the class Mystring:

“>>”: take the input of object of Mystring, i.e. 1st^ string size & than string

Main() { Mystring obj; Cin>>obj; }

“<<”: Show the output of object of Mystring, i.e. 1st^ string size & than string

Main() {

Eneter the Size of String: 25 Enter String: Mid-Exam was so easy

Your output is: The Size of String Allocated: 25 The Original Size of String: 20 String: Mid-Exam was so easy

Mystring obj; Cout<<obj; }

“+”: concatenate two objects & save in the 1st^ one

“=”: it will copy 2nd Mystring object to 1st^ object,

“-”: It will minus 2nd Mystring object to 1st^ object,

“!”: it will only change order as shown & also case of each char,

“!= ” : it will compare the two objects of Mystring(char* str ), if both objects not equal return true.

Example: 1st^ object have“Table” & 2nd^ object have “chair” when obj1+obj Than output on screen should be: Table & Chair

Example: 1st^ object have “Table” & 2nd object have “chair” when obj1=obj Than output on screen should be: chair

Example: 1st^ object have “FAMES” & 2nd object have “NAMED” when obj1-obj Than output on screen should be: FNSD

Example: 1st^ object have “table” than “!obj1” output will be: ELBAT

Example: 1st^ object have “FAMES” & 2nd^ object have “NAMED” when obj1!=obj Than output on screen should be: objects are not equal

Note: Ø Make all the necessary functions including constructor & destructor. File should be submitted. i.e., “rollno_A5”.delete Debug folder. Only zip Ø All code files should contain Roll Number, Name, Assignment Number and Date, e.g.:// Syed Mohammad Irteza // 07-0555// assignment Ø // 10/06/2009Your code should have appropriate comments. Ø Ø Use meaningful identifier names for variables and functions.Properly indent your code, to make it readable.

________________________________

________________________________