Beruflich Dokumente
Kultur Dokumente
Evoved from C
Varous Versons/Impementatons
ANSI/ISO
The Language
An OOPL
Typed Language
Man Features:
procedura
Namespaces
Genercs (tempates)
Stricter on typing
const nt c = 10;
constant nteger
const nt **ppp;
w ths work?
namespace H {
nt x = 10;
nt y = 10;
}
namespace G {
nt y=20;
usng namespace H;
}
nt man() {
usng namespace G;
cout << x << "\n" << y << "\n"; //w ths work?
}
namespace aliasing
namespace A = B;
usng namespace A;
you can use aasng wth condtona
processng
C in C++
extern "C"
extern "C" {
#ncude <stdo.h>
}
nt man () {
prntf ("heo\n"); // w ths work?
}
Symbol __cplusplus
o/p?
nt counter=0;
nt f() {
return counter
++;
}
nt x () { return 1;}
nt y () { return 2;}
nt z () { return 3;}
man () {
cout << x() << y() <<
z() << "\n";
cout << f() << f() <<
f() << "\n";
}
order of evaluation
o/p?
nt counter=0;
nt f() {
return counter ++;
}
vod h (nt p, nt q) {
cout << "p=" << p << " q="
<< q << "\n";
}
man () {
h( f(), f());
}
order or evaluation
(ex: nesting)
nested cas
nt counter=0;
nt f (nt p, nt q) {
return (p+q);
}
nt g(nt ) {
counter =;
cout << counter << end;
return counter;
};
man () {
cout << f( f ( f (1,g(9)),
g(7)),g(5)) << end;
}
Point of Declaration
whch |?
nt |=10;
nt man() {
nt =|,|;
| = 20;
cout << <<" " << | << "\n";
// what output?
}
-
explicit casting of void*
needed
nt =10;
vod *v;
v = &;
nt *|;
| = statc_cast<nt *>(v);
cout << *| << "\n";
}
virtual destructors
A *a = new B();
deete a;
B *b=new B();
deete b;
Koenig Lookup