Develop your own string class

Assignment Help Computer Engineering
Reference no: EM132137147

A string in C++ is simply an array of characters with the null character(\0) used to mark the end of the string. C++ provides a set of string handling function in as well as I/O functions in . With the addition of the STL (Standard Template Library), C++ now provides a string class.

But for this assignment, you are to develop your own string class. This will give you a chance to develop and work with a C++ class, define constructors and destructors, define member functions outside of the class body, develop a copy constructor and assignment operator (and understand why!), work with C-Style strings and pointers, dynamically allocate memory and free it when done.

Of course, you must also do suitable testing which implies writing a main function that uses your new string class.

The following is the skeleton of the Mystring class declaration. Mystring.h file is provided. You must produce the Mystring.cpp and main.cpp files.

class Mystring

{

private:

char *pData; //pointer to simple C-style representation of the string

//(i.e., sequence of characters terminated by null)

//pData is only a pointer. You must allocate space for

//the actual character data

int length; //length of the string

//... //possibly other private data

public:

MyString(); //constructor --- create empty string

MyString(char *cString); //constructor --- create a string whose data is a copy of

//cString

~MyString(); //destructor -- don't forget to free space allocated by the constructor

//i.e., the space allocated for the character data

MyString(MyString const& s); //override the default copy constructor --- why?

//important -- think about it -- possible test question

MyString operator = (MyString const& s); //override default assignment operator

void Put(); //output string

void Reverse(); //reverse the string

MyString operator + (MyString const& s); //concatenation operator

// ... //other useful member functions

//as you wish

};

Reference no: EM132137147

Questions Cloud

The risks associated planned procurement approach : Identify the risks associated planned procurement approach. how procurement risks for this project will be monitored and controlled.
Annual holding and setup costs : The soft goods department of a large department store sells 175 units per month of a certain large bath towel. annual holding and setup costs?
What is the complexity of any dynamic programming approach : What is the complexity of any dynamic programming approach based on parts a) and b), assume that s and t are of length a and b. Use Big Omega notation
Print the converted sentence both to the screen : Print the converted sentence both to the screen and to an output file. Your input file consists of a variable number of records.
Develop your own string class : Develop and work with a C++ class, define constructors and destructors, define member functions outside .
Which of the following statements will display a string : Which of the following statements will display a string as "Jones, Jane" (the last name, a comma, a space, and the first name) in the lblFullName control?
Write a method with an input variable : Write a method with an input variable (string type). The method should return the number of uppercase letters of the input variable.
Write a query that satisfies the given requirements : Write a query that satisfies the given requirements by making sure to use GROUP BY and HAVING clauses.
Prompts the user to input the shipping cost per liter : Amanda and Tyler opened a business that specializes in shipping liquids, such as milk, juice, and water, in cylinderical containers.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Is np closed under complement

Is NP closed under Complement ? In P , we can prove that it is closed under Complement. Why doesn't that analysis work for NP ?

  Define methods and instance variables for the class

Your assignment is to create a sketch that defines a class called "Tribble". A Tribble is a small fuzzy creature kept as a cute pet that breeds quickly.

  The difference between subnetting and supernetting

give the importance of subnetting with respect to collisions, broadcasts and controlling traffic. Discuss the difference between subnetting and supernetting.

  Express the difference between sequential file access

What is the difference between sequential file access, random file access, and binary file access? For each of the three types, give an instance of an application where the use of one type is better than the other two types.

  Write clearly and concisely about introductory information

write a four to fivenbsp page paper in which youdescribe what a relational database is and why relational databases are

  Communicate information effectively in a multimedia format

Produce documents and present work in multimedia formats appropriate for the intended audience and apply basic design elements, principles and techniques in different scenarios.

  Issues or problems related to database architecture

In a Microsoft Word document, write an 800- to 1,000-word research paper. Your research paper should contain the following sections.

  What part will the internet play in your plans

If you were responsible for setting up a network for a company that had offices in 5 different states, how would you do it? What part will the Internet play in your plans.

  What mips instruction will be executed

In a von Neumann architecture, groups of bits have no intrinsic meanings by themselves. What a bit pattern represents depends entirely on how it is used. Consider the following bit patterns expressed in hexadecimal notation.

  Design a clocked d flip flop

Design a clocked D flip-flop, using a modified ECL circuit design, such that the output becomes valid on the negative-going edge of the clock signal.

  List from challenges of implementing an erp system

How could core ERP components help improve business operations at a University? List from challenges of implementing an ERP system at a University.

  What are the basic goals of dijkstras least-cost algorithm

What are the basic goals of Dijkstra's least-cost algorithm? How can flooding be used to transmit a data packet from one end of the network to another?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd