Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

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

The creation of a custom string class named mystring. The class includes a char* and an integer size, and overloads various operators such as '>>', '<<', '+', '=', '-', '!', '!=', '==', ',', '&', '++', and '--'. The document also discusses the implementation of functions for constructors, destructors, and variable counting. Intended for university students studying c++ programming.

Typology: Exercises

2011/2012

Uploaded on 07/24/2012

omni
omni 🇮🇳

4.6

(9)

46 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

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.

________________________________

________________________________