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

int OVERLOADED_VOIP_FSM::operator == (int x) Please Write the above overload ope

ID: 3598742 • Letter: I

Question

int OVERLOADED_VOIP_FSM::operator == (int x)

Please Write the above overload operator using the information below: this operator is inside a class called OVERLOAD_VOIP_FSM. No need to write "int main{}" file. (C++)

An example use of overloaded operator == interface is as follows:

if (fsm1 == m)

where fsm1 is an object of class OVERLOADED_VOIP_FSM and m is an integer.
This overloaded operator checks if the number of states in fsm1 is equal to m.
If true, it returns 1 with the following output to out.4:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ OUTPUT FROM OVERLOADED OPERATOR == INTERFACE:
+++ RETURNS TRUE: THERE ARE m STATES.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

If the number of states is not equal to m, the overloaded operator
interface returns 0. The output to out.4 file is:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ OUTPUT FROM OVERLOADED OPERATOR == INTERFACE:
+++ RETURNS FALSE: THERE ARE NOT m STATES.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

MAKE SURE THAT EVERY LINE YOUR WRITE INTO out.4 ENDS WITH endl.

Explanation / Answer

-This is the program in C++ for the overloaded operator "==" for the class OVERLOADED_VOIP_FSM .Here I have taken one private data member for storing the number of states and there are three public member functions, one is constructor to create the object of the class, second is the overloaded operator function and third to access the private data member of class.

#include<iostream.h>

class OVERLOADED_VOIP_FSM

{

int No_Of_States; //private data member

public:

int operator==(int); //overloaded operator prototype

OVERLOADED_VOIP_FSM(int n)

{

No_Of_States=n;

}

int get_no_of_states()

{

return(No_Of_States);

}

};

int OVERLOADED_VOIP_FSM::operator == (int m)

{

int x;

cout<<"How many number of states?";

cin>>x;

OVERLOADED_VOIP_FSM fsm1(x);

if(fsm1.get_no_of_states()==m)

{

return(1);

cout<<"OUTPUT FROM OVERLOADED OPERATOR == INTERFACE: RETURNS TRUE: THERE ARE m STATES."<<endl;

}

else

{

return(0);

cout<<"OUTPUT FROM OVERLOADED OPERATOR == INTERFACE: RETURNS FALSE: THERE ARE NOT m STATES."<<endl;

}

}

-I have not written main() here as you told.Please give me feedback for this program.Here I didn't get the meaning of out.4, so I used cout for output. If you can clarify it then I can modify the program.Thank you