Question: B 1 Given test _ Str . cpp write the corresponding header file and implementation file ( Str . h , Str . cpp )

B1 Given test_Str.cpp write the corresponding header file and implementation file (Str.h, Str.cpp).
// test_Str.cpp
#include
#include "Str.h"
using namespace std;
int main()
{
Str s1;
char courseName[]="cpp";
Str s2(courseName);
Str s3(s2);
s2.print(); //cpp
s3.print(); //cpp
s1= s2; s1.print();
//cpp
++s1; s1.print();
//dqq
s1[0]='P'; s1.print(); //Pqq
return 0;
}
Hint: use the following information !!
//CONSTRUCTORS. Apply memory allocation for each constructor.
// First One: An empty constructor: only NULL character, Size:1
// Second One: Creates a string fills with arr's elements. arr can have different
size.
// Third One: Copy constructor. Source string object can have different size.
// OPERATORS
//== Assignment operator. Left-hand side string object can have different size.
// Apply memory allocation for the assignment operator
KOM3550 Object-Oriented Programming
Assignment 3
2
//++ Pre-increment. Increments the elements of the string by one value.
//[] Subscript operator: returns an lvalue through indexing.
// OTHER FUNCTIONS
// Display the string.
private:
int Size; // the Size of the string including NULL.
char* str;
// the pointer should point the characters of the string + NULL.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!