Comparison of Java and C++: Difference between revisions

Content deleted Content added
vector is usually a type name. Something like simply "a" is much more innocuous and acceptable.
Line 118:
// (from C++11)
public:
Foo() : x({0)} // Constructor for Foo; initializes
{} // x to 0. If the initializer were
// omitted, the variable would
Line 125:
 
int bar(int i) { // Member function bar()
return 3 * i + x;
}
};</syntaxhighlight>
Line 138:
 
public int bar(int i) { // Member method bar()
return 3 * i + x;
}
}</syntaxhighlight>
Line 192:
|-
| <syntaxhighlight lang="cpp">
Foo * c;
// declares c to be a pointer to a
// Foo object (initially
Line 211:
|-
| <syntaxhighlight lang="cpp">
Foo & d = *c;
// binds d to reference the same object to which c points</syntaxhighlight>
| <syntaxhighlight lang="java">
Line 254:
|-
| <syntaxhighlight lang="cpp">
const Foo * a; // it is not possible to modify the object
// pointed to by a through a
</syntaxhighlight>
Line 413:
! Java generated byte code
|-
| {{code|vectora[i]++;}}
| {{sxhl|2=nasm|mov edx,[ebp+4h]
mov eax,[ebp+1Ch]