473,396 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

order of calling overloaded operators

iterator classes provide overloaded operators like this in general:

template <typename T>
class Iterator
{
Iterator operator++(int); // postfix ++
T& operator*();
};

Iterator<int> i;
*i++;

You know postfix ++ has higher precedence than unary *.
Does it gaurantee that postfix ++ is called before unary * operator?

--
ES Kim
May 23 '06 #1
3 1694
ES Kim wrote:
iterator classes provide overloaded operators like this in general:

template <typename T>
class Iterator
{
Iterator operator++(int); // postfix ++
T& operator*();
};

Iterator<int> i;
*i++;

You know postfix ++ has higher precedence than unary *.
It`s the dereferencing operator, not unary * (which does not exist).
Does it gaurantee that postfix ++ is called before unary * operator?


Of course. The point of operator precedence is to guarantee the order
in which these operators are called.

*p++ is always *(p++) and a+b*c is always a+(b*c).
Jonathan

May 23 '06 #2
Jonathan Mcdougall wrote:
ES Kim wrote:
You know postfix ++ has higher precedence than unary *.


It's the dereferencing operator, not unary * (which does not exist).


Oh, come now. It's a unary operator represented by the symbol '*', and
you and everybody else knew exactly what the OP meant. In fact,
§5.3.1 [expr.unary.op] uses the exact term "the unary * operator" to
refer to this entity. Perhaps you just enjoy bullying, rather than
helping to inform? If you're going to be pedantic, have the decency to
be correct.

Luke

May 23 '06 #3
Luke Meyers wrote:
Jonathan Mcdougall wrote:
ES Kim wrote:
You know postfix ++ has higher precedence than unary *.
It's the dereferencing operator, not unary * (which does not exist).


Oh, come now. It's a unary operator represented by the symbol '*', and
you and everybody else knew exactly what the OP meant. In fact,
§5.3.1 [expr.unary.op] uses the exact term "the unary * operator" to
refer to this entity.


It was my intention to remove that line, but I forgot before posting. I
apologize.
Perhaps you just enjoy bullying, rather than
helping to inform? If you're going to be pedantic, have the decency to
be correct.


True.
Jonathan

May 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Brad Eck | last post by:
"The only operators that cannot be overloaded are :: (scope resolution), . (member selection), and .* (member selection through pointer to function). Quoting from Stroustrup's 3rd edition of _The...
4
by: masood.iqbal | last post by:
Please help me with this doubt that I have regarding overloaded operators. Sometimes they are member functions and sometimes they are friends (e.g. see the code snippet from Stroustrup, Second...
10
by: maadhuu | last post by:
hi i wasnt to know the answer for the following. now ,u can overload all the operators which are basically determined at runtime (coz' of whch operators like sizeof())cannot be overloaded. now...
1
by: Alex Zhitlenok | last post by:
Hi, My question is how to resolve in C# ambiguous overloaded operators? Let say, I have two unrelated classes A and B, each one implements overloaded operator + with the first parameter of type...
19
by: Babis Haldas | last post by:
i have if(i==1 && func1() ) do something if i!=1 , func1 doesnt run at all this is in my compiler is this because the compiler or because the stantard can i rely that in any system...
3
by: andreas ames | last post by:
Hi all, recently I came across a line of code like the following: if seq.erase(seq.begin(), seq.end()) != seq.end() /* ... */ It made me wonder if this is just bogus or if it even can...
5
by: raylopez99 | last post by:
I need an example of a managed overloaded assignment operator for a reference class, so I can equate two classes A1 and A2, say called ARefClass, in this manner: A1=A2;. For some strange reason...
6
by: LSW | last post by:
I've tried googling for the answer to this one, but haven't found anything. In the following code snippet BOOLEAN SomeValue; if(SomeValue && SomeFunc()) DoSomething; If SomeValue is False,...
54
by: Rasjid | last post by:
Hello, I have just joined and this is my first post. I have never been able to resolve the issue of order of evaluation in C/C++ and the related issue of precedence of operators, use of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.