Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Assignment Note : Other chegg users Please don\'t copy . We have to create a

ID: 3845230 • Letter: C

Question

C++ Assignment

Note : Other chegg users Please don't copy .

We have to create a FunnyNumber header, but I don't know how to proceed from now on, please edit my code. I have provided the Number header. In bold : what i have problem with. Thanks

Instructions:

Make a FunnyNumber.h header which extends Number.h, add two constructors to it

– Add a void reverse() function and implement it.

– Override operators + and == in FunnyNumber so they have a different behavior.

Here is Number.h

What I tried for FunnyNumber.h:

#ifndef FUNNYNUMBER_H
#define FUNNYNUMBER_H

#include<iostream>
#include<string>
#include"Number.h"
#include<algorithm>


using namespace std;

class FunnyNumber : public Number
{
public:
   //constructors
   FunnyNumber();
   FunnyNumber(string val);

   // Operator +
   virtual string operator+(const FunnyNumber &other)const;

   // Operator ==
   virtual bool operator==(const FunnyNumber &other)const;

Explanation / Answer

Answer for this Question:

I have implemented three functions which you mentioned in the question

void reverse(string &other)
{
int n = other.length();
char temp;
int i,j;
while(i<j)
{
       temp=other[i];
       other[i]=other[j];
       other[j]=temp;
       i++;
       j--;
}
}

virtual string operator+(const FunnyNumber &other)
{
FunnyNumber obj3;
int len=this.length()+other.length();
obj3.value=new char[len+1];

strcpy(obj3.value,this->value);
strcat(obj3.value,other.value);

return obj3.value;
}

virtual bool operator==(const FunnyNumber &other)
{
int rel=0;

if(strcmp(this->value,other.value)==0)
{
rel=1;
}
return rel;
}