Solved

28. Could we change operations priority while overloading?

Posted on 2015-01-24
5
75 Views
Last Modified: 2015-02-12
Could we change operations priority while overloading?
0
Comment
Question by:Nusrat Nuriyev
  • 2
  • 2
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 40568271
I am not quite sure what you mean here. Could you explain a bit more?
0
 
LVL 32

Accepted Solution

by:
phoffric earned 250 total points
ID: 40568665
Are you talking about operator precedence? If so, then the answer is no. Overload as you wish, but the precedence of the operator is fixed in C++.
0
 
LVL 32

Expert Comment

by:phoffric
ID: 40568672
I should have added that when two operators have the same precedence, then their associativity rules come into play, and that you cannot change those rules as well. (You know that to change the associativity, you use parenthesis.)
0
 

Author Comment

by:Nusrat Nuriyev
ID: 40606150
operators has priorities, can we change them at overloading?
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 250 total points
ID: 40606166
No, operator precedence is - as phoffric wrote above - 'carved in stone', See e.g. http://en.cppreference.com/w/cpp/language/operator_precedence 

Operator precedence is unaffected by operator overloading.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MSVCR80.dll crash 2 141
Arduino EDI - Programming language 3 104
Why isn't object file created? 6 69
DCT of  2D array using fftw in c++ 9 69
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question