Question

Might there be a way to directly access commonly used operators, such as the arithmetic operators...

Might there be a way to directly access commonly used operators, such as the arithmetic operators or the stream operators, with enumeration types? For example, would overloading these operators be a good solution? Why or why not? i need an explantion not a code . thank you

Homework Answers

Answer #1

OVERLOADING IN HIGH-LEVEL LANGUAGES LIKE CPP, JAVA , PYTHON IS NOT ONLY LIMITED TO FUNCTIONS BUT ALSO OPERATORS LIKE ARTHIMETIC , ASSIGNMENT OR STREAM OPERATORS .

THIS MEANS THESE OPERATORS USAGE IS NOT CONFINED TO ONLY THE BUILT-IN TYPES BUT ALSO USED ON CUSTOM CLASSES OR ENUMERATIONS .

NOW OVERLOADING THESE OPERATORS CAN MAKE IT EASIER TO ACCESS THESE OPERATORS IN USER DEFINED CLASSES OR ENUMERATIONS.

( EX : IN A STRING CLASS , + OPERATOR CAN BE OVERLOADED TO PERFORM CONCATENATION OPERATION )

OPERATOR OVERLOADING CAN MAKE IT EASIER TO PERFORM OPERATIONS ON THE OBJECTS OF USER DEFINED CLASSES . AND THUS MAKE THE CODE MORE ROBUST.

BUT ONE SHORT-COMING OF THESE APPROACH IS IT MAKES THE CODE COMPLICATED IN CASE OF LARGE CLASS DEFINATIONS,

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Project plans are commonly used by all types of organizations. An example using the construction of...
Project plans are commonly used by all types of organizations. An example using the construction of a new office building might be the task of obtaining government building permits, another might be the pouring of the concrete foundation. What are several other tasks that would be involved? Which of these do you consider the most important? Which do you think are the least important? Why?
(For Python) Evaluating Postfix Arithmetic Expressions. In this project you are to implement a Postfix Expression...
(For Python) Evaluating Postfix Arithmetic Expressions. In this project you are to implement a Postfix Expression Evaluator as described in section 7-3b of the book. The program should ask the user for a string that contains a Postfix Expression. It should then use the string's split function to create a list with each token in the expression stored as items in the list. Now, using either the stack classes from 7.2 or using the simulated stack functionality available in a...
Note: Do not use classes or any variables of type string to complete this assignment Write...
Note: Do not use classes or any variables of type string to complete this assignment Write a program that reads in a sequence of characters entered by the user and terminated by a period ('.'). Your program should allow the user to enter multiple lines of input by pressing the enter key at the end of each line. The program should print out a frequency table, sorted in decreasing order by number of occurences, listing each letter that ocurred along...
[PART ONE OF PROJECT, ALREADY COMPLETED] An accumulator is a primitive kind of calculator that can...
[PART ONE OF PROJECT, ALREADY COMPLETED] An accumulator is a primitive kind of calculator that can evaluate arithmetic expressions. In fact, the Arithmetic-Logic Unit (ALU) of the rst computers was just an accumulator. An arithmetic expression, as you know, consists of two kinds of tokens: operands and operators All our operands will be (float) numbers and for a start, we shall use only two operators: + (plus) and - (minus) A sample run of the program would look like this....
Please post all code in Pseudo code. Please post ORIGINAL answers do not copy from similar...
Please post all code in Pseudo code. Please post ORIGINAL answers do not copy from similar questions. Please post in a format that can be directly copied. Reasoning on answers would be most helpful but not required. Thank you in advance for your help. 1.Design an algorithm to find all the common elements in two sorted lists of numbers. For example, for the lists 2, 5, 5, 5 and 2, 2, 3, 5, 5, 7, the output should be 2,...
English writting This assignment addresses all the secondary influences surrounding a good presentation (that is, everything...
English writting This assignment addresses all the secondary influences surrounding a good presentation (that is, everything except the content of the speech). Imagine you've been asked to address an audience about a topic that's important to you. Consider how you would present this topic. What persona might you create? To do: Outline a short speech focusing on the structure of the presentation. You do not need to actually write the speech - just include enough information to make sense of...
I did already posted this question before, I did get the answer but i am not...
I did already posted this question before, I did get the answer but i am not satisfied with the answer i did the code as a solution not the description as my solution, so i am reposting this question again. Please send me the code as my solution not the description In this project, build a simple Unix shell. The shell is the heart of the command-line interface, and thus is central to the Unix/C programming environment. Mastering use of...
Prep Work Once you have a good feel for the different types of business structures, you...
Prep Work Once you have a good feel for the different types of business structures, you should be able to narrow the choice for your specific business idea down to a couple. Think about the different structures and your own situation. See if you can narrow down your thoughts to the one best for you. For example, sole proprietorship or partnership--a sole proprietorship has the most control and it's really easy to make a decision but a partnership has a...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
Ron Davis, the relatively new general manager of the machine tooling group at Parker Manufacturing, was...
Ron Davis, the relatively new general manager of the machine tooling group at Parker Manufacturing, was visiting one of the plants. He scheduled a meeting with Mike Leonard, a plant manager who reported to him. RON: Mike, I’ve scheduled this meeting with you because I’ve been reviewing performance data, and I wanted to give you some feedback. I know we haven’t talked face-to-face before, but I think it’s time we review how you’re doing. I’m afraid that some of the...