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
Define the Float Data Type of c Language? The float is used to define floating point numbers. The Floating point numbers are stored in 32 bits with 6 digits of precision. Eg

Write a program in C that you will name "divide.exe", to divide one 32-bit twos-complement binary number by another, giving the quotient and the remainder, using the subtract-shift


E x p r e s sion and their types: An expression will be in form of mathematical expression with C++ syntax embedded with it. Expressions are of following types which m

#questiowrite a program to calculate e^x


A: No. (Excluding if you have an old compiler, you might have to force the new operator to throw an exception if it runs out of memory.) This turns out to be a real pain to alwa


write a C program that can display the transpose form of a ciphertext matrix.

what is the function of spanning tree in graph algorithm?