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
Reference Types The symbol "&" is interpreted as an address operator as well as AND operator. This operator is also used to declare a "reference variable". A reference is refer

w.a.p to find outWrite a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.

I can''t figure out how to stop the programming from hitting for the player even when they type in stand.

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome


Explain the Working of strcpy Function? strcpy() : This function is meant to use to copy one string to another. The strcpy function as well accepts two strings as arguments.


Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

# include stdio.h> # include string.h> # include conio.h> void main() {           int i=0,j=0,b=0,count=0;           int a[100];           for(i=0;i

Draw pie chart in c++ program: int main() {                 char cmd;                   cout                 cout                 cmd = toupper(getch());