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
source code for padovan string


Write algorithm and program for the conversion of a Tree to a Binary Tree

This problem familiarizes you with using random numbers in C++. The program is to compute a good approximation of p using a simulation method called "Monte Carlo". The following fi

write c program to do the following : -fill 2 dimensional array (square matrix array with size=4). -ask the user to enter any integer number and add this number to the diagonals -o

Write a C++ program that calculates the area of a circle, rectangle and square using overloaded versions of a function area ().Your program should include both declarations and def

C program to add, average and deviation of numbers: void main() {                 int sum=0,a[10],i;                 float avg=0,dev,vari=0,var;                 pri

Looping Statements The statements usually used for looping are for, do-while, while. The goto statement can be used for looping, but its use is generally avoided as it leads to


A: BinarySearchTree.h ---------------------- #ifndef BINARY_SEARCH_TREE_H_ #define BINARY_SEARCH_TREE_H_ #include "dsexceptions.h" #include // For NULL // Binary