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?
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....
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...
Read the case and answer the following Multiple choice questions. There are 5 questions total, where...
Read the case and answer the following Multiple choice questions. There are 5 questions total, where some of them might have more than one correct answers. You can choose more than one options where you think is suitable for the above question. PERFORMANCE MANAGEMENT Project Manager Oliver Caine skimmed his notes as he waited for Ben Robins to come to the meeting room. He hoped Ben would arrive soon, as he wanted to get the con-versation finished quickly. Ben walked...
Acid-Base Behavior In addition to following the general safety rules, chemicals need to be handled properly....
Acid-Base Behavior In addition to following the general safety rules, chemicals need to be handled properly. In particular, two very important classes of compounds called acids and bases require special attention. These compounds are commonly used reagents in the laboratory; therefore, understanding their proper disposal is beneficial. Physical differences between acids and bases can be detected by the some of the five senses, including taste and touch. Acids have a sour or tart taste and can produce a stinging sensation...
To Make a Cup of Coffee, It Takes More Than a Village A journey of thanks...
To Make a Cup of Coffee, It Takes More Than a Village A journey of thanks for a simple daily pleasure reveals the miracle of a globalized economy. I recently had the opportunity to gaze at one of the most mind-boggling accomplishments in history. This marvel is the result of thousands of human beings collaborating across dozens of countries. It required the combined labor of artists, biologists, politicians, mechanics, miners and goatherds. It took airplanes, boats, trucks, motorcycles, vans, pallets...
The assignment summary sheets will be submitted week 14 with Test 3. You are to personally...
The assignment summary sheets will be submitted week 14 with Test 3. You are to personally experience the power and satisfaction of developing these skills firsthand and to reflect and write about this experience. Over the years, many students have shared amazingly rewarding experiences as they worked on these skills. The assignment will be evaluated and be weighted as 5% of your final mark (together, they are worth 20% of your mark for Test 3, which is worth 25% of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT