Write a C++ program to overload the increment and decrement operator.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

USE TEMPLATE PROVIDED AT END WHEN MAKING SOLUTION.MATCH OUTPUT AS IT IS

-------------------------------------
Write a C++ program to overload the increment and decrement operator.

Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement.

Consider a class named Contest and include the following private member variables.

Datatype

Variable

int

number1

int

number2

int

number3

int

number4

int

number5

Create a parameterized constructor with arguments in order Event(int number1,int number2,int number3,int number4,int number5)

Include the following public methods in the class Contest.

Method Name                                       

Description

void show(void)

This function is used to display the five numbers.

void operator ++()

This function is used to add each number by one using the '++' operator.

void operator --()

This function is used to subtract each number by one using the '--' operator

 
Input and Output Format:
Refer to sample input and output for formatting specifications.

[All text in bold corresponds to input and the rest corresponds to output]
Sample Input and Output 1 :
Enter the first number
9
Enter the second number
12
Enter the third number
20
Enter the fourth number
38
Enter the fifth number
19
Specify the option
plus
Response for plus
10, 13, 21, 39, 20
Specify the option
plus
Response for plus
11, 14, 22, 40, 21
Specify the option
plus
Response for plus
12, 15, 23, 41, 22
Specify the option
plus
Response for plus
13, 16, 24, 42, 23
Specify the option
minus
Response for minus
12, 15, 23, 41, 22
Specify the option
plus
Response for plus
13, 16, 24, 42, 23
Specify the option
minus
Response for minus
12, 15, 23, 41, 22
Specify the option
stop

 

------------------------TEMPLATES BELOW--------------------

 

MAIN.CPP

#include<cstring>
#include<iostream>
#include<string>
#include "Contest.cpp"
using namespace std;
int main()
{
//Fill your code here
}

 

CONTEST.CPP

using namespace std;

class Contest
{
//Fill your code here
public:
void show(void) {
//Fill your code here
}

void operator ++() {
//Fill your code here
}

void operator --() {
//Fill your code here
}

};

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY