Computer Science Homework Solutions
Problem
#5591

Classes in C++, implementing a member function.

I am having a dificult time understanding Classes in C++ and how to implement member functions. Given the attached code I need to:

1: Add the code to implement all of the member functions.
2: Test them from main as coded.
3: Show the order the constructors are called.
4: Show the order the destructors are called.

Attached file(s):
Attachments
mp1.txt  View File

Attachment Content Summary (Note: view attachment at the above link before purchasing. Actual attachment content may vary slightly from that shown below.)

mp1.txt
#include
#include
"


using namespace std;

class CString //class containing a string and functions to access the string
{
public:
CString(char *p); // allocates memory and copies p to m_pString
virtual ~CString(); // deletes the m_pString
char *GetString(){return m_pString ;} //inline function is already implemented
virtual ConvertString(){ cout << "nothing\n" ;} //inline function is done here
private:
char *m_pString; // the character data string
};

class CNumericString : public CString //derived from CString
{ //contains the numeric value of its base
public:
CNumericString(char *p); //its base constructor is initialized from here
~CNumericString(); // does nothing
int ConvertString(); // Converts the string of its base class to integer,
// using atoi and saves it
// in m_numericString.
private:
int m_numericString; // the numeric string of its base
};

void main()
{
CNumericString str("12345");
cout << str.GetString() << endl;
cout << str.ConvertString() << endl;
}
Solution
What is this?
By OTA - Overall OTA Rating
Jamshed Dastur, MSc (IP) - n/a
Purchase Cost Now
$2.19 CAD (was ~$15.96)
Included in Download
  • Plain text response
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • 13365 Programming > C++ - I am attempting to complete Assignemt Exercise 13.12 in the Deitel&Deitel 5th edition version of C++ How to program. I am running into some early errors in trying to incorporate the Date class into ...
  • Data Structures Using C++ - Data Structures Using C++. See attached file for full problem description.
  • C++ Programming - Create a class named RealtorCommission. Fields include the sale price of a house, the sales commission rate, and the commission. Create two constructors. Each constructor requires the sales price ( ...
  • Write a constructor - Can someone write a constructor method for the class "Dog" that uses the "this reference" and explain what it does?
  • Write an interactive Java program that illustrates the use of methods, constructors, loops and arrays. - Write an interactive Java program that illustrates the use of methods, constructors, loops and arrays. Your Program will do the following: 1. Ask the user for a String input of letters, i.e., Oh ...
Browse