1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Schach [20]
4 years ago
6

Explain by details operator overloading in C++ with example

Computers and Technology
1 answer:
dimaraw [331]4 years ago
8 0

Answer:

Operator overloading is used to extend the functionality of an operator like +(addition),-(subtraction),/(Division),*(Multiplication).

Syntax for operator overloading inside the class :-

You have to use operator keyword.

Function

return type operator <operator sign> (arguments)

{

     ---code

}

suppose you want to extend the functionality of ++ operator for any integer so that it increases the value by two.

void operator ++(int &a)

{

    a=a+2;

}

So whenever this operator is used with an argument it will increase the value to that argument by 2.

int a=5;

++(a);

a will become 7;

You might be interested in
Alarm filtering may be based on combinations of frequency, similarity in attack signature, similarity in attack target, or other
dezoksy [38]

Answer: False

Explanation:

 The given statement is false, as the alarm filtering is the process of classifying the various type of IDPS alert in the system and it can be managed more efficiently.

The IDPS administrator can easily set an alarm filtering in the running system. It can generate the various types of positive tract in the system and then adjust the different alarm classifications. Alarm filters are same as the packet filter in which they can easily filter the items from the source and destination IP address.

3 0
3 years ago
Write a program whose input is two integers and whose output is the two integers swapped.
Tpy6a [65]

Answer:

The program to this question can be given as:

Program:

#include <iostream>  //header file

using namespace std;   //using namespace.

void SwapValues(int* userVal1, int* userVal2); //function declaration.

void SwapValues(int* userVal1, int* userVal2) //function definition.

{ //function body.

//perform swapping

   int t = *userVal1;  

   *userVal1 = *userVal2;

   *userVal2 = t;

}

int main() //main method  

{

int n1, n2; //define variable

cout<<"Enter first number :"; //message

cin>>n1; //input by user.

cout<<"Enter second number :"; //message  

cin>>n2; //input by user.

SwapValues(&n1,&n2); //calling function.

cout<<"Swapped values"<<endl;

cout<<"first number is :"<<n1<<endl; //print value

cout<<"second number is:"<<n2<<endl; //print value

return 0;

}

Output:

Enter first number :3

Enter second number :8

Swapped values

first number is :8

second number is :3

Explanation:

The description of the above C++ language program can be given as:

  • In the program, firstly we include the header file. Then we declare and define a function that is "SwapValues()" function in the function we pass two integer variable that is "userVal1 and userVal2" inside a function, we define an integer variable that is "t" and perform swapping.  
  • Then we define the main function in the main function we define two variables that is "n1 and n2" this variable is used to take value-form user. then we pass this value to function and print the function values.

5 0
3 years ago
Powerpoint assumes that the first slide in a new presentation is the
fomenos
Powerpoint assumes that the first slide in a new presentation is the title slide
5 0
3 years ago
When i try to add a module into a device, packet tracer pop-ups a warning message saying "cannot add a module when the power is
Gre4nikov [31]
Save all your important pictures documents on a flash drive or cd but what ever you do remember to save it on icloud.com so you have a back up and reseat your  computer
8 0
3 years ago
Please I need help with this. How do I get rid of it. It blocks me from seeing questions or answering them.
anyanavicka [17]

Just try clicking the why am I seeing this and you might find yoir way out

Sorry there is nothing I can do since I've not seen it before

6 0
2 years ago
Other questions:
  • Lena has secured her online website, which sells fashion apparel. She has taken all the necessary steps by making her website PS
    8·1 answer
  • In the lab, the Ethernet II detail of the provided packet capture file indicated that Wireshark had determined that the ________
    5·1 answer
  • What type of wireless connection requires an unobstructed "line of sight" between transmitter and receiver?
    8·1 answer
  • A client contacted you to request your help in researching and supplying the hardware necessary to implement a SOHO solution at
    5·1 answer
  • Project 4: Strictly Identical arrays
    7·1 answer
  • Laura has many online accounts discuss the privacy concerns associated with individuals use of the Internet
    15·1 answer
  • Kathi, the owner of Klothes for Kats, is excited about the launch of her first Local Catalog ad. She remembers there are a few d
    6·1 answer
  • Write function that ask for input from a user. Use this input as input for the countdown function that we wrote using the while
    6·1 answer
  • The visitor's age is stored in the variable age, the day of the week is stored in a variable day, and the price in dollars is st
    8·1 answer
  • A _______ attack is where the input includes code that is then executed by the attacked system.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!