Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with my code, it's on line 45. I have no idea what this means #include #include #include using namespace std; class StringOperations

I need help with my code, it's on line 45. I have no idea what this means

image text in transcribed

#include

#include

#include

using namespace std;

class StringOperations

{

char str[20];

int len;

public:

StringOperations() { len = 0; }

void read()

{

cout

cin >> str;

}

int operator ~()

{

int i;

len = 0;

for (i = 0; str[i] != '\0'; i++)

{

len++;

}

return(len);

}

friend istream &operator >>(istream &in, StringOperations &s)

{

int i;

~s;

cout

for (i = s.len - 1; i >= 0; i--)

{

cout

}

}

void operator ==(StringOperations s)

{

read();

int i;

char str2[20];

for (i = 0; str[i] != '\0'; i++)

str2[i] = str[i];

str2[i] = '\0';

cout

cout

}

void operator +(StringOperations s2)

{

~*this;

int j = len;

for (int i = 0; s2.str[i] != '\0'; i++)

{

str[j] = s2.str[i];

j++;

}

str[j] = '\0';

cout

}

void operator =(StringOperations s2)

{

int i, f = 0;

for (i = 0; str[i] != '\0'; i++)

{

if (str[i] == s2.str[i])

{

f = 1;

}

else

f = 0;

break;

}

if (f == 1)

cout

else

cout

}

void operator ||(StringOperations s2)

{

int i, j = 0, f = 0, count = 0;

cout

for (i = 0; str[i] != '\0'; i++)

{

if (str[i] == s2.str[j])

{

j++;

}

else

{

j = 0;

}

if (s2.str[j] == '\0')

{

f = 1;

count++;

cout

j = 0;

}

}

cout

}

friend ostream &operator

{

out

return(out);

}

};

int main()

{

int c, l;

char m;

StringOperations s1, s2;

do

{

cout

cin >> c;

switch (c)

{

case 1: s1.read();

l = ~s1;

cout

break;

case 2: s1 == s2;

break;

case 3: s1.read();

cin >> s1;

break;

case 4: cout

cout

s1 + s2;

break;

case 5: cout

cout

s1 = s2;

break;

case 6: cout

cout

s1 || s2;

break;

case 7: exit(1);

break;

default:cout

break;

}

cout

cin>>m;

} while (c != 7);

return 0;

}

26 28 30 int i; len = 0; for (i -8; str[i]" it+) lent return(len); friend istrean Soperator (istrean &in, Stringoperations &5) 37 int i cout

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_2

Step: 3

blur-text-image_3

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

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions