Define constructors and destructors

Assignment Help Computer Engineering
Reference no: EM132137993

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 <string.h> as well as I/O functions in <iostream>.

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

};

In addition, prepare a graphical explanation of each of your member functions. (Pseudo code or flowchart or some diagram to show your design.)

Reference no: EM132137993

Questions Cloud

Evaluate the limitations of network-based defensive tools : Evaluate the limitations of three network-based defensive tools. Based upon your evaluation, provide plausible explanations of how the hackers avoided detection
What are the main things to remember about elasticity : What are the main things to remember about elasticity, supply and demand, tax incidence, government controls on the market, and economic theories?
Write a function obenglobish that takes an english word : Write a function obenglobish that takes an English word and returns its Obenglobish equivalent, using the translation rule given above.
How many bytes does this string take in the memory : If a string is stored at the memory address 0 times 20008000 and the string is "Cortex-M", show the memory content in hex format starting at 0 times 20008000.
Define constructors and destructors : Define constructors and destructors, define member functions outside of the class body, develop a copy constructor and assignment operator.
How can an analyst identify appropriate sample distributions : Having a strong statistical picture of data is important to being able to properly identify trends in statistical analysis.
Create a program called lastnomeupanddown take a string : Create a program called lastnomeupAndDown take a string input from the user and print out that will substrings of increasing length.
Design your method so that it works quickly even : Design your method so that it works quickly even if k is greater than the length of s, maybe even as large as +1,000,000,000.
Write a loop that will display the students that have : Write a loop that will display the students that have "A" or "B" next to their names. If the stuent has a "A" next to their names, cout "Good".

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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