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
Problem 1 What is the difference between function declaration and function definition? 2 Write a recursive function to find sum of even numbers from 2 to 10. 3 List some

Differentiate between the expression "++a" and "a++"? - With ++a, increment happens first on variable a, and resulting value is used. This is known as prefix increment. - Wi

Differentiate between a template class and class template in C++? Ans) Template class: A generic definition or a parameterized class not instantiated until the client gives the

What is a hash function? Hash function: This is the method from the set 'K' of keys into the set 'L' of memory addresses.   H: K → L These are used to verify the address

A: The procedure of encoding the parameter types along with the function/method name into a unique name is called as name mangling. The inverse procedure is called demangling. F

I really have a hard time analyzing how to write a code in C. It''s all bout Time Departure and we must used a 24 hour clock. Can u help me?

Write a function to calculate the exchange rate of pounds to dollars  Answer       Td = 2xTp   The parameter passed over is the number of pounds and returned the value in do


Hi, Can i get a quote for my Programming assignment

write the program to accept date and to say valid or invalid