#include <iostream.h> main() { int i = 3; cout << i; for (int j = 0; j < 10; j++) cout << j; }Καλό είναι οι μεταβλητές να ορίζονται ακριβώς πριν από το πρώτο σημείο όπου χρησιμοποιούνται.
int i; // This is a line comment; set i to 8. i = 8;
int y = 8; int &x = y; x = 3; // Set y to 3
#include <iostream.h> double square(double x); int square(int x); double square(double x) { return (x * x); } int square(int x) { return (x * x); } main() { int i = 3; double d = 1.4142; cout << "square(" << i << ")=" << square(i) << "\n"; cout << "square(" << d << ")=" << square(d) << "\n"; }
struct point { int x, y; }; point *p; main() { p = new point; delete p; }
main() { int *ip = new int[10]; ip[3] = 8; delete[] ip; }