Re: pre, post increment standard behaviour, and friend function declaration
From: Rolf Magnus (ramagnus_at_t-online.de)
Date: 01/26/04
- Next message: Jorge Rivera: "Re: 8 years of C++ Exception Handling"
- Previous message: Fred H: "Re: sector , file and partition reading in C++"
- In reply to: eddiew_AUS: "pre, post increment standard behaviour, and friend function declaration"
- Next in thread: eddiew_AUS: "Re: pre, post increment standard behaviour, and friend function declaration"
- Reply: eddiew_AUS: "Re: pre, post increment standard behaviour, and friend function declaration"
- Reply: Kevin Goodsell: "Re: pre, post increment standard behaviour, and friend function declaration"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 26 Jan 2004 15:12:10 +0100
eddiew_AUS wrote:
> while playing around to check <blah> for my personal project,
What is "<blah>"?
> I discovered an anomaly with my code, compiled using (cringe) visual
> studio ver 6:
>
>
> #include<iostream>
>
> using namespace std;
>
> int main( void )
> {
> int k = 3;
> cout << k;
> cout << " " << k++ << " " << k << " " << ++k << " ";
> cout << k << "\n";
> }
>
> produces the expected output of:
> 3 4 4 4 5
I don't see why you would expect that.
>
> while
>
> #include<iostream>
>
> using namespace std;
>
> int main( void )
> {
> int k = 3;
> cout << k;
> cout << " " << k++ << " " << k << " " << ++k << " " << k << "\n";
> }
>
> produced the output of
> 3 4 4 4 3
>
> Q: Is this another example of non-standard microsoft compilers, or a
> result of the chained function calls?
It's the result of changing k's value multiple times without a sequence
point in between. The behaviour of that code is undefined.
> And another question:
> Q: Is it possible to declare the constructor of class B as a friend
> function to class A, and if so what is the syntax?
I don't think so. Constructors don't have a name.
- Next message: Jorge Rivera: "Re: 8 years of C++ Exception Handling"
- Previous message: Fred H: "Re: sector , file and partition reading in C++"
- In reply to: eddiew_AUS: "pre, post increment standard behaviour, and friend function declaration"
- Next in thread: eddiew_AUS: "Re: pre, post increment standard behaviour, and friend function declaration"
- Reply: eddiew_AUS: "Re: pre, post increment standard behaviour, and friend function declaration"
- Reply: Kevin Goodsell: "Re: pre, post increment standard behaviour, and friend function declaration"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|