Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

operator overloading c++ part 1: Complete the definition of the class given below such that the main program runs successfully. Make sure that your program

operator overloading

c++

part 1:

Complete the definition of the class given below such that the main program runs successfully. Make sure that your program doesnt consume extra memory space and it should not leak any memory.

class Set{

private:

int* elements; //To save elements of a Set

int size; //Total number of elements in a Set

};

void main()

{

int arr1[] = {10,20,30,40};

Set s1(arr1 , 4);//Creates a Set with elements of arr1 and size = 4

int arr2[] = {5,15,55};

Set s2(arr2 , 3);//Creates a Set with elements of arr2 and size = 3

cout<<"Set 1:\t"<

Set s3;

s3 = s1+s2; //Takes sorted Union of s1 and s2

cout<<"Set 3:\t"<

int arr3[] = {1,2,100,-1}; //-1 is delimiter

s3 = arr3 + s1; //Returns sorted Union

cout<<"Set 3:\t"<

cout<

cout<

}

part 2:

Write exact sequence of function calls for following code:

part 2:

s3 = arr1 + s2 + arr3;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions