Can one create operator** for "to-the-power-of" operations?, C/C++ Programming

A: no, can't.

The names of, precedence of, associativity of, and arity of operators is fixed through the language. In C++, there is no operator** so you cannot create one for a class type.

If you have a doubt, assume that x ** y is the same as x * (*y) (in other terms, the compiler suppose y is a pointer). As well, operator overloading is only syntactic sugar for function calls. Although this specific syntactic sugar can be very sweet, it doesn't add anything fundamental. I recommend you overload pow (base,exponent) (double precision version is in ).

By the way, operator^ can work for to-the-power-of, except it contain the wrong associatively and precedence.

 

 

Posted Date: 3/20/2013 3:47:18 AM | Location : United States







Related Discussions:- Can one create operator** for "to-the-power-of" operations?, Assignment Help, Ask Question on Can one create operator** for "to-the-power-of" operations?, Get Answer, Expert's Help, Can one create operator** for "to-the-power-of" operations? Discussions

Write discussion on Can one create operator** for "to-the-power-of" operations?
Your posts are moderated
Related Questions
What are header files? What are their uses? - Header files are also known as library files. - They carry two significant things: definitions and prototypes of functions bein

Webcam Driver static library or DLL required for Windows I want a .dll or .lib file using which i will take a snapshot from the webcam and it can't turn on the webcam LED while

FIT 3042 System Tools and Programming Languages Semester 1 2013 Assignment 1 An SDL video player for a custom video format Worth: 20% of final mark. Must be completed individually

Objectives: The objective of this assignment is to use C++ to queue students into an array-based queue for BCS registration. Students have the option of taking five different cours

Write a function that takes in a number n and divides the screen into n vertical bars, alternating black and white. (What should you do if someone puts in n=0 or n=-99?)

how can I find the GCD of 2 given numbers using Euclidean Algorithm ?

¦It should ask customers to enter details such as their names and addresses. ¦It should print a welcome message that includes the customer’s name. ¦It should provide a list of avai

one of the segments is showing compilation error...

#include #include #include #include #include class Employee { private: char *Name; //Set them as pointers... int IdNumber; char *Department; char *Position; public: voi

Explain protected, public, private in C++? These are three access spaecifiers in C++. - Public - Here data members and functions are accessible outside the class. - Pr