Einzelnen Beitrag anzeigen

Newbie44
(Gast)

n/a Beiträge
 
#1

[C++] Frage zu Post- und Preincrement

  Alt 19. Dez 2007, 18:53
Hallo,

ich hab diese Beispiele neulich gefunden blicke aber nicht so ganz durch was diese genau machen.

Code:
a)   i=1;i = i+ ++i ; cout<<i<<endl;   //4
b)   i=1;i = i++ +i;  cout<<i<<endl;    //3
c)   i=1;i = i+ i++ ; cout<<i<<endl;   //3
d)   i=1;i = ++i + ++i;cout<<i<<endl;    //6
e)   i=1;i = ++i + i++;cout<<i<<endl;   //5
f)   i=1;i = i+++ ++i; cout<<i<<endl;    //5
g)   i=1;i += i+ ++i;  cout<<i<<endl;   //6
h)   i=1;i += i+++ i;  cout<<i<<endl;    //4
i)   i=1;i += ++i+ ++i; cout<<i<<endl;   //9
j)   i=1;i += ++i+ i++; cout<<i<<endl;    //7
k)   i=1;i += i+++ ++i; cout<<i<<endl;   //7
l)   i=1;i += i+++ i++; cout<<i<<endl;    //5
m)   i=1;i += i++ **j ; cout<<i<<endl;   //3
n)   i=1;i += ++i**j ; cout<<i<<endl;    //6
o)   i=1;i*= ++*j **j; cout<<i<<endl;    //8
p)   char x='d'+'A'-'a';cout<<x<<endl;   //D
in den kommentar stehen die ergebnisse.

das mit dem preincrement und einmal postincrement ist mir etwas rätselhaft.

könnte mir das bitte noch jemand erklären?

vielen dank im voraus
  Mit Zitat antworten Zitat