E
Eric Lilja
I'm looking at an assignment where the students are expected to write a
class with a given purpose. According to the assignment, you should be
able to do this with instances of the class:
++instance_of_class;
instance_of_class++;
(++instance_of_class)++; // Isn't this invalid C++?
but not:
++(instance_of_class++);
But doesn't the third thing the class should support,
(++instance_of_class)++;, violate the rule that says that a variable
may not be modified more than once between two sequence points or else
undefined behaviour is the result? I'm not looking to start a heated
discussion here, just want confirmation or denial from the gurus here
before I let the person behind the assignment know about his mistake
(if, in fact, he made one).
/ Eric
class with a given purpose. According to the assignment, you should be
able to do this with instances of the class:
++instance_of_class;
instance_of_class++;
(++instance_of_class)++; // Isn't this invalid C++?
but not:
++(instance_of_class++);
But doesn't the third thing the class should support,
(++instance_of_class)++;, violate the rule that says that a variable
may not be modified more than once between two sequence points or else
undefined behaviour is the result? I'm not looking to start a heated
discussion here, just want confirmation or denial from the gurus here
before I let the person behind the assignment know about his mistake
(if, in fact, he made one).
/ Eric