Test 2 / Sem 2 / Programare C++
Part 1
1
struct
A
{
int b;
void c(int d) { b=d; }
public: int e;
void f(int g) { b=g; }
} *m;
main() { m=new A; ... }
Expresii corecte
void c(int d) { b=d; }
public: int e;
void f(int g) { b=g; }
} *m;
main() { m=new A; ... }
Expresii corecte
m->c(10)
m->f(10)
m->e=10
m->b=10
2
Cum
pot fi accesaţi membrii privaţi ai unei structuri ?
funcţii membru publice
3
Structura
C++ are implicit toţi membrii: public
4
class
my { int a;
public: void get_a() { cout << "a="; cin >> a; }
void show_a(int a){ cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(a); }
Ce afisează? a= 25
public: void get_a() { cout << "a="; cin >> a; }
void show_a(int a){ cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(a); }
Ce afisează? a= 25
5
Care
definiţii sunt corecte?
struct
S { int y; S *z; };
class
A; struct E { int z; A& x; };
6
class
my { int a;
public: void get_a() { cout << "a="; cin >> a; }
void show_a(int a=15) { cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(); }
Ce afişează? a= 15
public: void get_a() { cout << "a="; cin >> a; }
void show_a(int a=15) { cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(); }
Ce afişează? a= 15
7
Ce
este o instanţă? obiect de o anumită clasă
8
8
class
my { int a;
public: void get_a() { cout << "a="; cin >> a; }
void show_a() { cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(23); }
Ce afişează? Mesaj de eroare
public: void get_a() { cout << "a="; cin >> a; }
void show_a() { cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(23); }
Ce afişează? Mesaj de eroare
9
class my { int a;
public: void show_a(int a=15) { cout << this->a; }
void get_a() { cout << "a="; cin >> a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(); }
Ce afişează? Numărul introdus
10
class my { int a;
public: void show_a(int a=15) { cout << this->a; }
void get_a() { cout << "a="; cin >> a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(); }
Ce afişează? Numărul introdus
10
class my { int a;
public: void get_a() { cout << "a=";
cin >> a; }
void show_a(int a) { cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(15); }
Ce afişează? 15
void show_a(int a) { cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(15); }
Ce afişează? 15
11
În
C++ structura poate fi membru al unei clase
Răspuns:
Adevărat
12
class
A { int b;
void c(int d) { b=d; }
public: int e;
void f(int g) { b=g; }
} x, *w, t[3];
main() { w=new A; ... }
Câte exemplare de fiecare membru al clasei vor fi alocate în memorie? 1 1 1 1
void c(int d) { b=d; }
public: int e;
void f(int g) { b=g; }
} x, *w, t[3];
main() { w=new A; ... }
Câte exemplare de fiecare membru al clasei vor fi alocate în memorie? 1 1 1 1
13
class my { int a;
public: void get_a() { cout << "a="; cin >> a; }
void show_a(int a=15) { int a=35; cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(45); }
Ce afişează? Mesaj de eroare
14
Ce este incapsularea? Modul de ascundere a datelor şi funcţiilor în definiţia unei clase prin protecţia lor
15
class my { int a;
public: void get_a() { cout << "a="; cin >> a; }
void show_a(int a=15) { int a=35; cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(45); }
Ce afişează? Mesaj de eroare
14
Ce este incapsularea? Modul de ascundere a datelor şi funcţiilor în definiţia unei clase prin protecţia lor
15
class my { int a;
public: void show_a(int a=15) { cout << my::a; }
void get_a() { cout << "a="; cin >> a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(); }
Ce afişează? Numărul introdus
16
struct A { int b;
void get_a() { cout << "a="; cin >> a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(); }
Ce afişează? Numărul introdus
16
struct A { int b;
void c(int d) { b=d; }
public: int e;
void f(int g) { b=g; }
} m;
Care expresii sunt corecte?
public: int e;
void f(int g) { b=g; }
} m;
Care expresii sunt corecte?
m.b=10
m.c(10)
m.f(10)
m.e=10
17
17
class
a { int b;
void c(void) { b=26; cout << b; }
} d;
main() { d.b=16; cout << d.b; }
Ce va afişa? Mesaj de eroare!
void c(void) { b=26; cout << b; }
} d;
main() { d.b=16; cout << d.b; }
Ce va afişa? Mesaj de eroare!
18
struct
A { int x; char g[57]; } w, *s;
Care expresii sunt corecte?
s->g
w.g
s->x
w.x
19
Care
parte a definiţiei unei clase defineşte modul de implementare a unui TAD? Întrega
definiţie
20
struct
S { int a,b;
public: void S23() { a=2; b=3; }
void show() { cout << a << ' ' << b; }
} w;
main() { w.show(); }
Ce va afişa? 0 0 Lipseste raspunsul correct
public: void S23() { a=2; b=3; }
void show() { cout << a << ' ' << b; }
} w;
main() { w.show(); }
Ce va afişa? 0 0 Lipseste raspunsul correct
21
class
S { int a,b;
public: S23() { a=2; b=3; }
} x,y,z;
main() { z=x*y; }
Ce valoare are z? Eroare la compilare
public: S23() { a=2; b=3; }
} x,y,z;
main() { z=x*y; }
Ce valoare are z? Eroare la compilare
22
class
A { char n[27]; } *w[5];
main() { for(int i = 0; i < 5; i++ )
w[i] = new A; ... }
Care expresii sunt corecte? nici una
main() { for(int i = 0; i < 5; i++ )
w[i] = new A; ... }
Care expresii sunt corecte? nici una
23
struct
A { int b;
void c(int d) { b=d; }
public: int e;
void f(int g) { b=g; }
} m, *n;
main() { n=new A; ... }
Care expresii sunt corecte? m.b; n->c(10); n->b; m.c(10);
void c(int d) { b=d; }
public: int e;
void f(int g) { b=g; }
} m, *n;
main() { n=new A; ... }
Care expresii sunt corecte? m.b; n->c(10); n->b; m.c(10);
24
Cum pot
fi accesaţi membrii privaţi ai unei clase? funcţii membru publice
25
class
my { int a;
public: void get_a() { cout << "a="; cin >> a; }
void show_a() { cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(a); }
Ce afişează? Mesaj de eroare
public: void get_a() { cout << "a="; cin >> a; }
void show_a() { cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(a); }
Ce afişează? Mesaj de eroare
26
class my { int a;
public: void show_a(int a=15) { cout << my::a; }
void get_a() { cout << "a="; cin >> a; } };
main() { int a=25;
my *ob;
ob.get_a();
ob.show_a(); }
Ce afişează? Mesaj de eroare
public: void show_a(int a=15) { cout << my::a; }
void get_a() { cout << "a="; cin >> a; } };
main() { int a=25;
my *ob;
ob.get_a();
ob.show_a(); }
Ce afişează? Mesaj de eroare
27
class my { int a;
public: void get_a() { cout << "a="; cin >> a; }
void show_a(int a=15) { cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(35); }
Ce afişează? 35
28
struct a { int b;
public: void get_a() { cout << "a="; cin >> a; }
void show_a(int a=15) { cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(35); }
Ce afişează? 35
28
struct a { int b;
void c(void) { b=26; cout << b; }
} d;
main() { d.b=16; cout << d.b; }
Ce va afişa? 16
} d;
main() { d.b=16; cout << d.b; }
Ce va afişa? 16
29
struct
A { int b;
static int c;
public: void d(int e) { b=e; }
};
int c=0;
A m, n;
Câte exemplare de fiecare membru al clasei vor fi alocate în memorie? 212
static int c;
public: void d(int e) { b=e; }
};
int c=0;
A m, n;
Câte exemplare de fiecare membru al clasei vor fi alocate în memorie? 212
30
class
my { int a;
public: void get_a() { cout << "a="; cin >> a; }
void show_a() { cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(); }
Ce afişează? Numărul introdus
public: void get_a() { cout << "a="; cin >> a; }
void show_a() { cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(); }
Ce afişează? Numărul introdus
31
class
S { int a,b;
public: S23() { a=2; b=3; }
} w;
main() {cout << w.a+w.b; }
Ce va afişa? Eroare la compilare
public: S23() { a=2; b=3; }
} w;
main() {cout << w.a+w.b; }
Ce va afişa? Eroare la compilare
32
class
my { int a;
public: void get_a() { cout << "a="; cin >> a; }
void show_a(int a=15) { cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(); }
Ce afişează? 15
public: void get_a() { cout << "a="; cin >> a; }
void show_a(int a=15) { cout << a; } };
main() { int a=25;
my ob;
ob.get_a();
ob.show_a(); }
Ce afişează? 15
33
class
my { int a;
public: void get.a() { cout << "a="; cin >> a; }
void show.a() { cout << a; } };
main() { int a=25;
my ob;
ob.get.a();
ob.show.a(); }
Ce afişează? Mesaj de eroare
public: void get.a() { cout << "a="; cin >> a; }
void show.a() { cout << a; } };
main() { int a=25;
my ob;
ob.get.a();
ob.show.a(); }
Ce afişează? Mesaj de eroare
Part 2
1
class my { int a;
public: my();
void show_a(); };
my::my() { cout << "a="; cin >> a; a=25;}
void my::show_a() { cout << a; }
main() { my ob;
int a=25;
ob.show_a(); }
Ce afişează? 25 iniţializat
2
class my { int a;
public: my(int a=1) { my::a=8; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my(3);
p->show_a();
p->~my(); }
Ce afişează? 8 Aici destructorul
public: my();
void show_a(); };
my::my() { cout << "a="; cin >> a; a=25;}
void my::show_a() { cout << a; }
main() { my ob;
int a=25;
ob.show_a(); }
Ce afişează? 25 iniţializat
2
class my { int a;
public: my(int a=1) { my::a=8; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my(3);
p->show_a();
p->~my(); }
Ce afişează? 8 Aici destructorul
3
class my { int a;
public: my(int a) { my::a=5; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my[3];
for(int i=0; i<3; i++)
p[i].show_a(); }
Ce afişează? Mesaj de eroare
4
class my { int a, b;
public: my(int a=1, int b=2) { my::a=a; my::b=6; }
void show_a() { cout << " " << a << " " << b; } };
main() { my a[2][3]={ my(1,2), my(), 1, 2, my(3), my(3,4) };
for(int i=0; i<2; i++)
{ for(int j=0; j<3; j++)
a[i][j].show_a();
cout << endl; } }
Ce afişează? 1 6 1 6 1 6 2 6 3 6 3 6
5
class my { int a;
public: my(int a) { my::a=3; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my[5];
for(int i=0; i<3; i++)
p[i].show_a(); }
Ce afişează? Mesaj de eroare
6
class my { int a;
public: my(int a);
my();
void show_a(); };
my::my(int a) { my::a=a; }
my::my() { cout << "a="; cin >> a; }
void my::show_a() { cout << a; }
main() { my ob=my();
int a=25;
ob.show_a(); }
Ce afişează? Numărul introdus
7
class S { int a,b;
public: S() { a=2; b=3; }
} w;
main() { cout << w.a+w.b; }
Ce va afişa? Eroare la compilare
8
class my { int a;
public: my(int a);
my();
void show_a(); };
my::my(int a) { my::a=a; }
my::my() { cout << "a="; cin >> a; }
void my::show_a() { cout << a; }
main() { my ob=my();
int a=125;
ob.show_a(); }
Ce afişează? Numărul introdus
9
class my { int a;
public: my(int a);
my();
void show_a(); };
my::my(int a) { my::a=a; }
my::my() { cout << "a="; cin >> a; }
void my::show_a() { cout << a; }
main() { my& ob;
int a=25;
ob.show_a(); }
Ce afişează? Mesaj de eroare
10
class my { int a;
public: my(int a=4) { my::a=a; }
my() { a=5; }
void show_a() { cout << " " << a; } };
main() { my a[4]={1,2,3,4};
for(int i=0; i<4; i++)
a[i].show_a(); }
Ce afişează? 1 2 3 4
11
class my { int a;
public: my(int a=1) { my::a=5; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my(3);
p->show_a(); }
Ce afişează? 5
12
class my { int a;
public: my(int a=5) { my::a=1; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
void f(my& b) { b.show_a(); }
main() { my a(3);
f(a); }
Ce afişează? 1
13
class my { int a;
public: my(int a=35) { my::a=a; }
~my() { cout << " Aici destructorul!"; }
void show_a(); };
void my::show_a() { cout << a; }
main() { my ob;
int a=25;
ob.show_a(); }
Ce afişează? 35
14
class my { int a;
public: my(int a);
void show_a(); };
my::my(int a) { my::a=a; }
void my::show_a() { cout << a; }
main() { my ob(15);
int a=25;
ob.show_a();}
Ce afişează? 15
15
class my { int a;
public: my(int a=4) { my::a=a; }
my() { a=5; }
void show_a() { cout << " " << a; } };
main() { my a[4]={0,1,2,3,4};
for(int i=0; i<4; i++)
a[i].show_a(); }
Ce afişează? Mesaj de eroare
16
class S { int a,b;
public: S() { a=2; b=3; }
} x,y,z;
main() { z=x*y; ... }
Ce valoare are z? Eroare la compilare
17
struct S { int a,b;
public: S() { a=2; b=3; }
void show() { cout << a << ' ' << b; }
} w;
main() { w.show(); }
Ce va afişa? 2 3
18
class my { int a;
public: my(int a);
void show_a(); };
my::my(int a) { my::a=a; }
void my::show_a() { cout << a; }
main() { my ob(25);
int a=15;
ob.show_a();}
Ce afişează? 25
19
class my { int a;
public: my(int a=1) { my::a=5; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
void f(my *b) { b->show_a(); }
main() { my a(3);
f(&a); }
Ce afişează? 5
20
class my { int a;
public: my(int a);
my();
void show_a(); };
my::my(int a) { my::a=a; }
my::my() { cout << "a="; cin >> a; }
void my::show_a() { cout << a; }
main() { my ob();
int a=25;
ob.show_a(); }
Ce afişează? Mesaj de eroare
21
class my { int a;
public: my(int a) { my::a=5; }
my() { a=1; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my[3];
for(int i=0; i<3; i++)
{ p[i].show_a();
p[i].~my(); } }
Ce afişează? 1 Aici destructorul! 1Aici destructorul! 1 Aici destructorul!
22
class my { int a;
public: my(int a=1) { my::a=2; }
void show_a() { cout << a; } };
main() { my ob(3), *p=&ob;
p->show_a(); }
Ce afişează? 2
23
class my { int a;
public: my();
void show_a(); };
my::my() { cout << "a="; cin >> a; }
void my::show_a() { cout << a; }
main() { my ob;
int a=25;
ob.show_a(); }
Ce afişează? Numărul inrodus
24
class my { int a;
public: my(int a);
my();
void show_a(); };
my::my(int a) { my::a=a; }
my::my() { cout << "a="; cin >> a; }
void my::show_a() { cout << a; }
main() { my ob(28);
int a=25;
ob.show_a(); }
Ce afişează? Lipseşte răspunsul corect
25
class my { int a;
public: my(int a=5) { my::a=1; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
void f(my c) { c.show_a(); }
main() { my a(3);
f(a); }
Ce afişează? 1 Aici destructorul!
26
class my { int a;
public: my(int a) { my::a=5; }
my() { }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my[3];
for(int i=0; i<3; i++)
p[i].show_a(); }
Ce afişează? Lipseşte răspunsul corect
27
class my { int a;
public: my();
void showa(); };
my::my() { cout << "a="; cin >> a; }
void my::showa() { cout << a; }
main() { my ob;
int a=25;
ob.showa(); }
Ce afişează? Numărul inrodus
28
class my { int a;
public: my(int a);
my();
void show_a(); };
my::my(int a) { my::a=a; }
my::my() { cout << "a="; cin >> a; }
void my::show_a() { cout << a; }
main() { my ob;
int a=25;
ob.show_a(); }
Ce afişează? Numărul introdus
29
class my { int a;
public: my(int a) { my::a=5; }
my() { a=1; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my[3];
for(int i=0; i<3; i++)
{ p[i].show_a();
p[i].~my(); } }
Ce afişează? 1 1 1 Aici destructorul! Aici destructorul! Aici destructorul!
30
class my { int a;
public: my(int a=1) { my::a=5; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my(3);
p->show_a();
p->~my(); }
Ce afişează? 5 Aici destructorul!
31
class my { int a;
public: my(int a=1) { my::a=2; }
void show_a() { cout << a; } };
main() { my ob(3); my& p=ob;
p->show_a(); }
Ce afişează? Mesaj de eroare
32
class my { int a;
public: my( int a);
void show_a(); };
my::my(int a=35) { my::a=a; }
void my::show_a() { cout << a; }
main() { my ob(15);
int a=25;
ob.show_a(); }
Ce afişează? 15
33
class my { int a;
public: my(int a=1) { my::a=5; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
void f(my& b) { b.show_a(); }
main() { my a(3);
f(a); }
Ce afişează? 5
public: my(int a) { my::a=5; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my[3];
for(int i=0; i<3; i++)
p[i].show_a(); }
Ce afişează? Mesaj de eroare
4
class my { int a, b;
public: my(int a=1, int b=2) { my::a=a; my::b=6; }
void show_a() { cout << " " << a << " " << b; } };
main() { my a[2][3]={ my(1,2), my(), 1, 2, my(3), my(3,4) };
for(int i=0; i<2; i++)
{ for(int j=0; j<3; j++)
a[i][j].show_a();
cout << endl; } }
Ce afişează? 1 6 1 6 1 6 2 6 3 6 3 6
5
class my { int a;
public: my(int a) { my::a=3; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my[5];
for(int i=0; i<3; i++)
p[i].show_a(); }
Ce afişează? Mesaj de eroare
6
class my { int a;
public: my(int a);
my();
void show_a(); };
my::my(int a) { my::a=a; }
my::my() { cout << "a="; cin >> a; }
void my::show_a() { cout << a; }
main() { my ob=my();
int a=25;
ob.show_a(); }
Ce afişează? Numărul introdus
7
class S { int a,b;
public: S() { a=2; b=3; }
} w;
main() { cout << w.a+w.b; }
Ce va afişa? Eroare la compilare
8
class my { int a;
public: my(int a);
my();
void show_a(); };
my::my(int a) { my::a=a; }
my::my() { cout << "a="; cin >> a; }
void my::show_a() { cout << a; }
main() { my ob=my();
int a=125;
ob.show_a(); }
Ce afişează? Numărul introdus
9
class my { int a;
public: my(int a);
my();
void show_a(); };
my::my(int a) { my::a=a; }
my::my() { cout << "a="; cin >> a; }
void my::show_a() { cout << a; }
main() { my& ob;
int a=25;
ob.show_a(); }
Ce afişează? Mesaj de eroare
10
class my { int a;
public: my(int a=4) { my::a=a; }
my() { a=5; }
void show_a() { cout << " " << a; } };
main() { my a[4]={1,2,3,4};
for(int i=0; i<4; i++)
a[i].show_a(); }
Ce afişează? 1 2 3 4
11
class my { int a;
public: my(int a=1) { my::a=5; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my(3);
p->show_a(); }
Ce afişează? 5
12
class my { int a;
public: my(int a=5) { my::a=1; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
void f(my& b) { b.show_a(); }
main() { my a(3);
f(a); }
Ce afişează? 1
13
class my { int a;
public: my(int a=35) { my::a=a; }
~my() { cout << " Aici destructorul!"; }
void show_a(); };
void my::show_a() { cout << a; }
main() { my ob;
int a=25;
ob.show_a(); }
Ce afişează? 35
14
class my { int a;
public: my(int a);
void show_a(); };
my::my(int a) { my::a=a; }
void my::show_a() { cout << a; }
main() { my ob(15);
int a=25;
ob.show_a();}
Ce afişează? 15
15
class my { int a;
public: my(int a=4) { my::a=a; }
my() { a=5; }
void show_a() { cout << " " << a; } };
main() { my a[4]={0,1,2,3,4};
for(int i=0; i<4; i++)
a[i].show_a(); }
Ce afişează? Mesaj de eroare
16
class S { int a,b;
public: S() { a=2; b=3; }
} x,y,z;
main() { z=x*y; ... }
Ce valoare are z? Eroare la compilare
17
struct S { int a,b;
public: S() { a=2; b=3; }
void show() { cout << a << ' ' << b; }
} w;
main() { w.show(); }
Ce va afişa? 2 3
18
class my { int a;
public: my(int a);
void show_a(); };
my::my(int a) { my::a=a; }
void my::show_a() { cout << a; }
main() { my ob(25);
int a=15;
ob.show_a();}
Ce afişează? 25
19
class my { int a;
public: my(int a=1) { my::a=5; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
void f(my *b) { b->show_a(); }
main() { my a(3);
f(&a); }
Ce afişează? 5
20
class my { int a;
public: my(int a);
my();
void show_a(); };
my::my(int a) { my::a=a; }
my::my() { cout << "a="; cin >> a; }
void my::show_a() { cout << a; }
main() { my ob();
int a=25;
ob.show_a(); }
Ce afişează? Mesaj de eroare
21
class my { int a;
public: my(int a) { my::a=5; }
my() { a=1; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my[3];
for(int i=0; i<3; i++)
{ p[i].show_a();
p[i].~my(); } }
Ce afişează? 1 Aici destructorul! 1Aici destructorul! 1 Aici destructorul!
22
class my { int a;
public: my(int a=1) { my::a=2; }
void show_a() { cout << a; } };
main() { my ob(3), *p=&ob;
p->show_a(); }
Ce afişează? 2
23
class my { int a;
public: my();
void show_a(); };
my::my() { cout << "a="; cin >> a; }
void my::show_a() { cout << a; }
main() { my ob;
int a=25;
ob.show_a(); }
Ce afişează? Numărul inrodus
24
class my { int a;
public: my(int a);
my();
void show_a(); };
my::my(int a) { my::a=a; }
my::my() { cout << "a="; cin >> a; }
void my::show_a() { cout << a; }
main() { my ob(28);
int a=25;
ob.show_a(); }
Ce afişează? Lipseşte răspunsul corect
25
class my { int a;
public: my(int a=5) { my::a=1; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
void f(my c) { c.show_a(); }
main() { my a(3);
f(a); }
Ce afişează? 1 Aici destructorul!
26
class my { int a;
public: my(int a) { my::a=5; }
my() { }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my[3];
for(int i=0; i<3; i++)
p[i].show_a(); }
Ce afişează? Lipseşte răspunsul corect
27
class my { int a;
public: my();
void showa(); };
my::my() { cout << "a="; cin >> a; }
void my::showa() { cout << a; }
main() { my ob;
int a=25;
ob.showa(); }
Ce afişează? Numărul inrodus
28
class my { int a;
public: my(int a);
my();
void show_a(); };
my::my(int a) { my::a=a; }
my::my() { cout << "a="; cin >> a; }
void my::show_a() { cout << a; }
main() { my ob;
int a=25;
ob.show_a(); }
Ce afişează? Numărul introdus
29
class my { int a;
public: my(int a) { my::a=5; }
my() { a=1; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my[3];
for(int i=0; i<3; i++)
{ p[i].show_a();
p[i].~my(); } }
Ce afişează? 1 1 1 Aici destructorul! Aici destructorul! Aici destructorul!
30
class my { int a;
public: my(int a=1) { my::a=5; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my(3);
p->show_a();
p->~my(); }
Ce afişează? 5 Aici destructorul!
31
class my { int a;
public: my(int a=1) { my::a=2; }
void show_a() { cout << a; } };
main() { my ob(3); my& p=ob;
p->show_a(); }
Ce afişează? Mesaj de eroare
32
class my { int a;
public: my( int a);
void show_a(); };
my::my(int a=35) { my::a=a; }
void my::show_a() { cout << a; }
main() { my ob(15);
int a=25;
ob.show_a(); }
Ce afişează? 15
33
class my { int a;
public: my(int a=1) { my::a=5; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
void f(my& b) { b.show_a(); }
main() { my a(3);
f(a); }
Ce afişează? 5
34
class my { int a;
public: my(int a=3) { my::a=1; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
void f(my c) { c.show_a(); }
main() { my a(5);
f(a); }
Ce afişează? 1 Aici destructorul!
35
class my { int a;
public: my(int a=1) { my::a=2; }
void show_a() { cout << a; } };
main() { my ob(3); my& p=ob;
p.show_a(); }
Ce afişează? 2
36
class my { int a;
public: my(int a=1) { my::a=3; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
void f(my *b) { b->show_a(); }
main() { my a(5);
f(&a); }
Ce afişează? 3
37
class my { int a;
public: my(int a=1) { my::a=3; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my(5);
p->show_a();
p->~my(); }
Ce afişează? 3 Aici destructorul!
public: my(int a=3) { my::a=1; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
void f(my c) { c.show_a(); }
main() { my a(5);
f(a); }
Ce afişează? 1 Aici destructorul!
35
class my { int a;
public: my(int a=1) { my::a=2; }
void show_a() { cout << a; } };
main() { my ob(3); my& p=ob;
p.show_a(); }
Ce afişează? 2
36
class my { int a;
public: my(int a=1) { my::a=3; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
void f(my *b) { b->show_a(); }
main() { my a(5);
f(&a); }
Ce afişează? 3
37
class my { int a;
public: my(int a=1) { my::a=3; }
~my() { cout << " Aici destructorul!"; }
void show_a() { cout << " " << a; } };
main() { my *p; p=new my(5);
p->show_a();
p->~my(); }
Ce afişează? 3 Aici destructorul!
Part 3
1
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator -(int b) { return ( (a-b)%5 ); } };
main() { my a;
int c;
c=a-3;
cout << c; }
Ce afişează? Restul impartirii (a-3)/5, Valoarea a-3 modulo 5
2
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator +(int b) { return ( (a%1+b)%3 ); } };
main() { my a;
int c;
c=a+7;
cout << c; }
Ce afişează? Lipseşte răspunsul corect
3
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator +(int b) { return ( (a+b)%3 ); } };
main() { my a;
int c;
c=a+7;
cout << c; }
Ce afişează? Restul impartirii (a+7)/3, Valoarea a+7 modulo 3
4
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator /(int b) { return ( (a/b)%2 ); } };
main() { my a;
int c;
c=1/(3/a);
cout << c; }
Ce afişează? Mesaj de eroare
5
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator -(int b) { return ( (a-b)%5 ); } };
main() { my a;
int c;
c=-(3-a);
cout << c; }
Ce afişează? Mesaj de eroare
6
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator /(int b) { return ( (a/b)%2 ); } };
main() { my a;
int c;
c=a/3;
cout << c; }
Ce afişează? 1, când câtul numerelor a şi 3 este impar; 0, când câtul numerelor a şi 3 este par
7
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator *(int b) { return ( (a*b)%1 ); } };
main() { my a;
int c;
c=a*3;
cout << c; }
Ce afişează? 0
8
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator +(int b) { return ( (a+b)%3 ); } };
main() { my a;
int c;
c=7+a;
cout << c; }
Ce afişează? Mesaj de eroare
9
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator *(int b) { return ( (a*b)%2 ); } };
main() { my a;
int c;
c=a*3;
cout << c; }
Ce afişează? 1, dacă produsul numerelor a şi 3 este impar; 0, dacă produsul numerelor a şi 3 este par
10
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator -(int b) { return ( (a-b)%5 ); } };
main() { my a;
int c;
c=a- -3;
cout << c; }
Ce afişează? Valoarea a+3 modulo 5; Restul impartirii (a+3)/5
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator -(int b) { return ( (a-b)%5 ); } };
main() { my a;
int c;
c=a-3;
cout << c; }
Ce afişează? Restul impartirii (a-3)/5, Valoarea a-3 modulo 5
2
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator +(int b) { return ( (a%1+b)%3 ); } };
main() { my a;
int c;
c=a+7;
cout << c; }
Ce afişează? Lipseşte răspunsul corect
3
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator +(int b) { return ( (a+b)%3 ); } };
main() { my a;
int c;
c=a+7;
cout << c; }
Ce afişează? Restul impartirii (a+7)/3, Valoarea a+7 modulo 3
4
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator /(int b) { return ( (a/b)%2 ); } };
main() { my a;
int c;
c=1/(3/a);
cout << c; }
Ce afişează? Mesaj de eroare
5
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator -(int b) { return ( (a-b)%5 ); } };
main() { my a;
int c;
c=-(3-a);
cout << c; }
Ce afişează? Mesaj de eroare
6
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator /(int b) { return ( (a/b)%2 ); } };
main() { my a;
int c;
c=a/3;
cout << c; }
Ce afişează? 1, când câtul numerelor a şi 3 este impar; 0, când câtul numerelor a şi 3 este par
7
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator *(int b) { return ( (a*b)%1 ); } };
main() { my a;
int c;
c=a*3;
cout << c; }
Ce afişează? 0
8
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator +(int b) { return ( (a+b)%3 ); } };
main() { my a;
int c;
c=7+a;
cout << c; }
Ce afişează? Mesaj de eroare
9
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator *(int b) { return ( (a*b)%2 ); } };
main() { my a;
int c;
c=a*3;
cout << c; }
Ce afişează? 1, dacă produsul numerelor a şi 3 este impar; 0, dacă produsul numerelor a şi 3 este par
10
class my { int a;
public: my() { cout << "a="; cin >> a; }
void show_a() { cout << a; }
int operator -(int b) { return ( (a-b)%5 ); } };
main() { my a;
int c;
c=a- -3;
cout << c; }
Ce afişează? Valoarea a+3 modulo 5; Restul impartirii (a+3)/5
Part 4
1
class
A { protected:int a;
public:A(int x=7){a=0;}};
class B: public A { int b;
void show(){ cout << a << endl; }
public:B(int x=5){b=x;}};
int main() {
B y(3); y.show();
return 0; }
Ce afişează ? compilation error
public:A(int x=7){a=0;}};
class B: public A { int b;
void show(){ cout << a << endl; }
public:B(int x=5){b=x;}};
int main() {
B y(3); y.show();
return 0; }
Ce afişează ? compilation error
2
class
A { protected: int a;
public:A(int x=3){a=x;}};
class B: public A { int b;
public:B(int x=5){b=x;}
void show(){ cout << a << endl; }};
int main() {
B y(7); y.show();
return 0; }
Ce afişează ? 3
public:A(int x=3){a=x;}};
class B: public A { int b;
public:B(int x=5){b=x;}
void show(){ cout << a << endl; }};
int main() {
B y(7); y.show();
return 0; }
Ce afişează ? 3
3
class
A { int a;
public:A(int x=3){a=x;}
private:void show(){ cout << a << endl; }};
class B: private A { int b;
public:B(int x=5){b=0;}};
int main() {
B y(7); y.show();
return 0; }
Ce extrage ? compilation error
public:A(int x=3){a=x;}
private:void show(){ cout << a << endl; }};
class B: private A { int b;
public:B(int x=5){b=0;}};
int main() {
B y(7); y.show();
return 0; }
Ce extrage ? compilation error
4
class
A { protected:int a;
public:A(int x=3){a=0;}};
class B: public A { int b;
protected:void show(){ cout << a << endl; }
public:B(int x=7){b=x;}};
int main() {
B *p=new B(5);
p->show();
return 0; }
Ce extrage ? compilation error
public:A(int x=3){a=0;}};
class B: public A { int b;
protected:void show(){ cout << a << endl; }
public:B(int x=7){b=x;}};
int main() {
B *p=new B(5);
p->show();
return 0; }
Ce extrage ? compilation error
5
class
A { public:int a;
public:void show(){ cout << a << endl; }
A(int x=5){a=x;}};
class B: private A { protected:int b;
public:void show(){ cout << b << endl; }
B(int x=7){b=0;}};
class C: public B { int c;
public:void show(){ cout << a+b+c << endl; }
C(int x=3){c=x;}};
int main() {
C w(9);
w.show();
return 0; }
Ce afişează ? compilation error
public:void show(){ cout << a << endl; }
A(int x=5){a=x;}};
class B: private A { protected:int b;
public:void show(){ cout << b << endl; }
B(int x=7){b=0;}};
class C: public B { int c;
public:void show(){ cout << a+b+c << endl; }
C(int x=3){c=x;}};
int main() {
C w(9);
w.show();
return 0; }
Ce afişează ? compilation error
6
class
A { public:int a;
public:void show(){ cout << a << endl; }
A(int x=3){a=x;}};
class B: protected A { int b;
public:void show(){ cout << b << endl; }
B(int x=5){b=x;}};
class C: public B { int c;
public:void show(){ cout << a+b+c << endl; }
C(int x=9){c=x;}};
int main() {
C w(7);
w.show();
return 0; }
Ce afişează ? compilation error
public:void show(){ cout << a << endl; }
A(int x=3){a=x;}};
class B: protected A { int b;
public:void show(){ cout << b << endl; }
B(int x=5){b=x;}};
class C: public B { int c;
public:void show(){ cout << a+b+c << endl; }
C(int x=9){c=x;}};
int main() {
C w(7);
w.show();
return 0; }
Ce afişează ? compilation error
7
class
A { int a;
public:A(int x=7){a=x;}
protected:void show(){ cout << a << endl; }};
class B: public A { int b;
public:B(int x=5){b=x;}};
int main() {
B y(3); y.show();
return 0; }
Ce extrage ? compilation error
public:A(int x=7){a=x;}
protected:void show(){ cout << a << endl; }};
class B: public A { int b;
public:B(int x=5){b=x;}};
int main() {
B y(3); y.show();
return 0; }
Ce extrage ? compilation error
8
class
A { protected:int a;
public:A(int x=7){a=x;}};
class B: public A { protected:int b;
void show(){ cout << a << endl; }
public:B(int x=3){b=0;}};
int main() {
B y(5); y.show();
return 0; }
Ce afişează ? compilation error
public:A(int x=7){a=x;}};
class B: public A { protected:int b;
void show(){ cout << a << endl; }
public:B(int x=3){b=0;}};
int main() {
B y(5); y.show();
return 0; }
Ce afişează ? compilation error
9
class
A { int a;
public:A(int x=3){a=x;}
void show(){ cout << a << endl; }};
class B: public A { int b;
public:B(int x=5){b=x;}};
int main() {
B y(7); y.show();
return 0; }
Ce extrage ? 3
public:A(int x=3){a=x;}
void show(){ cout << a << endl; }};
class B: public A { int b;
public:B(int x=5){b=x;}};
int main() {
B y(7); y.show();
return 0; }
Ce extrage ? 3
10
class
A { int a;
public:A(int x=5){a=x;}
private:void show(){ cout << a << endl; }};
class B: public A { int b;
public:B(int x=7){b=x;}};
int main() {
B y(3); y.show();
return 0; }
Ce extrage ? compilation error
public:A(int x=5){a=x;}
private:void show(){ cout << a << endl; }};
class B: public A { int b;
public:B(int x=7){b=x;}};
int main() {
B y(3); y.show();
return 0; }
Ce extrage ? compilation error
11
class
A { int a;
public:A(int x=3){a=0;}
private:void show(){ cout << a << endl; }};
class B: protected A { int b;
public:B(int x=5){b=x;}};
int main() {
B y(7); y.show();
return 0; }
Ce extrage ? compilation error
public:A(int x=3){a=0;}
private:void show(){ cout << a << endl; }};
class B: protected A { int b;
public:B(int x=5){b=x;}};
int main() {
B y(7); y.show();
return 0; }
Ce extrage ? compilation error
12
class
A { protected:int a;
public:A(int x=3){a=x;}};
class B: public A { int b;
public:void show(){ cout << a << endl; }
B(int x=5){b=x;}};
int main() {
B *p=new B(7);
p->show();
return 0; }
Ce extrage ?3
public:A(int x=3){a=x;}};
class B: public A { int b;
public:void show(){ cout << a << endl; }
B(int x=5){b=x;}};
int main() {
B *p=new B(7);
p->show();
return 0; }
Ce extrage ?3
13
class
A { int a;
public:A(int x=3){a=x;}
void show(){ cout << a << endl; }};
class B: protected A { int b;
public:B(int x=5){b=x;}};
int main() {
B y(7); y.show();
return 0; }
Ce extrage ? compilation error
public:A(int x=3){a=x;}
void show(){ cout << a << endl; }};
class B: protected A { int b;
public:B(int x=5){b=x;}};
int main() {
B y(7); y.show();
return 0; }
Ce extrage ? compilation error
14
class
A { int a;
public:A(int x=5){a=x;}};
class B: public A { int b;
public:B(int x=3){b=0;}
void show(){ cout << a << endl; }};
int main() {
B y(7); y.show();
return 0; }
Ce afişează ? compilation error
public:A(int x=5){a=x;}};
class B: public A { int b;
public:B(int x=3){b=0;}
void show(){ cout << a << endl; }};
int main() {
B y(7); y.show();
return 0; }
Ce afişează ? compilation error
15
class
A { int a;
public:A(int x=5){a=x;}
void show(){ cout << a << endl; }};
class B: pivate A { int b;
public:B(int x=3){b=x;}};
int main() {
B y(7); y.show();
return 0; }
Ce extrage ? compilation error
public:A(int x=5){a=x;}
void show(){ cout << a << endl; }};
class B: pivate A { int b;
public:B(int x=3){b=x;}};
int main() {
B y(7); y.show();
return 0; }
Ce extrage ? compilation error
16
class
A { int a;
public:A(int x=7){a=x;}
protected:void show(){ cout << a << endl; }};
class B: protected A { int b;
public:B(int x=3){b=x;}};
int main() {
B y(5); y.show();
return 0; }
Ce extrage ? compilation error
public:A(int x=7){a=x;}
protected:void show(){ cout << a << endl; }};
class B: protected A { int b;
public:B(int x=3){b=x;}};
int main() {
B y(5); y.show();
return 0; }
Ce extrage ? compilation error
17
class
A { int a;
public:A(int x=3){a=x;}
protected:void show(){ cout << a << endl; }};
class B: private A { int b;
public:B(int x=7){b=x;}};
int main() {
B y(5); y.show();
return 0; }
Ce extrage ? compilation error
public:A(int x=3){a=x;}
protected:void show(){ cout << a << endl; }};
class B: private A { int b;
public:B(int x=7){b=x;}};
int main() {
B y(5); y.show();
return 0; }
Ce extrage ? compilation error
18
class
A { public:int a;
public:void show(){ cout << a << endl; }
A(int x=3){a=x;}};
class B: public A { protected:int b;
public:void show(){ cout << b << endl; }
B(int x=5){b=x;}};
class C: public B { int c;
public:void show(){ cout << a+b+c << endl; }
C(int x=7){c=x;}};
int main() {
C w(9);
w.show();
return 0; }
Ce afişează ?17
public:void show(){ cout << a << endl; }
A(int x=3){a=x;}};
class B: public A { protected:int b;
public:void show(){ cout << b << endl; }
B(int x=5){b=x;}};
class C: public B { int c;
public:void show(){ cout << a+b+c << endl; }
C(int x=7){c=x;}};
int main() {
C w(9);
w.show();
return 0; }
Ce afişează ?17
Part 5
1
class
A {protected: double x,y;
virtual void show(){cout << x+y << endl;}
public:A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
void show(){cout << x-y << endl;}
public:B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
void show(){cout << x*y << endl;}
public: C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&c;
p->show();
return 0; }
Ce extrage ? compilation error
virtual void show(){cout << x+y << endl;}
public:A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
void show(){cout << x-y << endl;}
public:B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
void show(){cout << x*y << endl;}
public: C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&c;
p->show();
return 0; }
Ce extrage ? compilation error
2
class
A {protected: double x,y;
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&a;
p->show();
return 0; }
Ce extrage ?3
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&a;
p->show();
return 0; }
Ce extrage ?3
3
class
A {protected: double x,y;
virtual void show(){cout << x+y << endl;}
public:A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&a;
p->show();
return 0; }
Ce extrage ? compilation error
virtual void show(){cout << x+y << endl;}
public:A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&a;
p->show();
return 0; }
Ce extrage ? compilation error
4
class
f{public:virtual double s()=0;};
class r: public f {double a,b;
public:double s(){return a*b;}
r(double a=3, double b=4){this->a=a;this->b=b;}};
class c: public f {double r;
public: double s(){return M_PI*r*r;}
c(double r=0){c::r=r;}};
int main()
{ f *p; r b; c d(1);
p=&d; cout << p->s() << endl;
return 0; }
Ce extrage ? compilation error
class r: public f {double a,b;
public:double s(){return a*b;}
r(double a=3, double b=4){this->a=a;this->b=b;}};
class c: public f {double r;
public: double s(){return M_PI*r*r;}
c(double r=0){c::r=r;}};
int main()
{ f *p; r b; c d(1);
p=&d; cout << p->s() << endl;
return 0; }
Ce extrage ? compilation error
5
class
A {protected: double x,y;
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p->show();
return 0; }
Ce extrage ? run time error
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p->show();
return 0; }
Ce extrage ? run time error
6
class
A {protected: double x,y;
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public:C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&c;
p->show();
return 0; }
Ce extrage ?3
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public:C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&c;
p->show();
return 0; }
Ce extrage ?3
7
class
f{public:virtual double s()=0;};
class r: public f {double a,b;
public:double s(){return a*b;}
r(double a=3, double b=4){this->a=a;this->b=b;}};
class c: public f {double r;
public: double s(){return M_PI*r*r;}
c(double r=0){c::r=r;}};
int main()
{ f *p=new f; r b; c d(1);
p=&b; cout << p->s() << endl;
return 0; }
Ce extrage ? compilation error
class r: public f {double a,b;
public:double s(){return a*b;}
r(double a=3, double b=4){this->a=a;this->b=b;}};
class c: public f {double r;
public: double s(){return M_PI*r*r;}
c(double r=0){c::r=r;}};
int main()
{ f *p=new f; r b; c d(1);
p=&b; cout << p->s() << endl;
return 0; }
Ce extrage ? compilation error
|
|
8
class
A {protected: double x,y;
virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&c;
p->show();
return 0; }
Ce extrage ? compilation error
virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&c;
p->show();
return 0; }
Ce extrage ? compilation error
9
class
A {protected: double x,y;
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&b;
p->show();
return 0; }
Ce extrage ?-1
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&b;
p->show();
return 0; }
Ce extrage ?-1
10
class
A {protected: double x,y;
virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&b;
p->show();
return 0; }
Ce extrage ? compilation error
virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&b;
p->show();
return 0; }
Ce extrage ? compilation error
11
class
f{public:virtual double s()=0;};
class r: public f {double a,b;
public:double s(){return a*b;}
r(double a=3, double b=4){this->a=a;this->b=b;}};
class c: public f {double r;
public: double s(){return M_PI*r*r;}
c(double r=0){c::r=r;}};
int main()
{ f *p; r b; c d(1);
p=&b; cout << p->s() << endl;
return 0; }
Ce extrage ? compilation error
class r: public f {double a,b;
public:double s(){return a*b;}
r(double a=3, double b=4){this->a=a;this->b=b;}};
class c: public f {double r;
public: double s(){return M_PI*r*r;}
c(double r=0){c::r=r;}};
int main()
{ f *p; r b; c d(1);
p=&b; cout << p->s() << endl;
return 0; }
Ce extrage ? compilation error
12
class
A {protected: double x,y;
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
(p=&b)->show();
return 0; }
Ce extrage ?-1
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
(p=&b)->show();
return 0; }
Ce extrage ?-1
13
class
A {protected: double x,y;
virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&a;
p->show();
return 0; }
Ce extrage ? compilation error
virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&a;
p->show();
return 0; }
Ce extrage ? compilation error
14
class
A {protected: double x,y;
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
(p=&c)->show();
return 0; }
Ce extrage ?30
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
(p=&c)->show();
return 0; }
Ce extrage ?30
15
class
A {protected: double x,y;
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&b;
p->show();
return 0; }
Ce extrage ?3
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&b;
p->show();
return 0; }
Ce extrage ?3
16
class
A {protected: double x,y;
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public:C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
(p=&c)->show();
return 0; }
Ce extrage ?-1
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public:C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
(p=&c)->show();
return 0; }
Ce extrage ?-1
17
class
A {protected: double x,y;
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public:C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
(p=&c)->show();
return 0; }
Ce extrage ?3
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public:C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
(p=&c)->show();
return 0; }
Ce extrage ?3
18
class
A {protected: double x,y;
virtual void show(){cout << x+y << endl;}
public:A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
void show(){cout << x-y << endl;}
public:B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&b;
p->show();
return 0; }
Ce extrage ? compilation error
virtual void show(){cout << x+y << endl;}
public:A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
void show(){cout << x-y << endl;}
public:B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&b;
p->show();
return 0; }
Ce extrage ? compilation error
|
|
|
19
class
f{public:virtual double s()=0;};
class r: public f {double a,b;
public:double s(){return a*b;}
r(double a=3, double b=4){this->a=a;this->b=b;}};
class c: public f {double r;
public: double s(){return M_PI*r*r;}
c(double r=0){c::r=r;}};
int main()
{ f *p=new f; r b; c d(1);
p=&d; cout << p->s() << endl;
return 0; }
Ce extrage ? compilation error
class r: public f {double a,b;
public:double s(){return a*b;}
r(double a=3, double b=4){this->a=a;this->b=b;}};
class c: public f {double r;
public: double s(){return M_PI*r*r;}
c(double r=0){c::r=r;}};
int main()
{ f *p=new f; r b; c d(1);
p=&d; cout << p->s() << endl;
return 0; }
Ce extrage ? compilation error
20
class
A {protected: double x,y;
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public:C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&c;
p->show();
return 0; }
Ce extrage ?-1
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public:C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&c;
p->show();
return 0; }
Ce extrage ?-1
21
class
A {protected: double x,y;
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&c;
p->show();
return 0; }
Ce extrage ?30
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
p=&c;
p->show();
return 0; }
Ce extrage ?30
22
class
A {protected: double x,y;
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
(p=&b)->show();
return 0; }
Ce extrage ?3
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
(p=&b)->show();
return 0; }
Ce extrage ?3
23
class
A {protected: double x,y;
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
(p=&a)->show();
return 0; }
Ce extrage ?3
public:virtual void show(){cout << x+y << endl;}
A(double x=1, double y=2){A::x=x;A::y=y;}};
class B: public A {protected: int x,y;
public:void show(){cout << x-y << endl;}
B(int x=3, int y=4){B::x=x;B::y=y;}};
class C: public B {unsigned x,y;
public: void show(){cout << x*y << endl;}
C(unsigned x=5, unsigned y=6){C::x=x;C::y=y;}};
int main()
{ A a, *p; B b; C c;
(p=&a)->show();
return 0; }
Ce extrage ?3