1.
Kód: Vybrat vše
class Base {
public:
vurtual Base operator+ (const Base &) const;
}
class Complex;
class Real:public Base {
public:
virtual Base operator+ (const Base &) const;
virtual Real operator+ (const Real &) const;
virtual Complex operator+ (const Complex &) const;
}
class Complex:public Base {
public:
virtual Base operator+ (const Base &) const;
virtual Real operator+ (const Real &) const;
virtual Complex operator+ (const Complex &) const;
}
Real r;
Complex c;
Base &b = r;
b = b + c
A. Real::operator+ (const Base &) const [X]
B. Complex::operator+ (const Complex &) const
C. Complex::operator+ (const Base &) const
D. Complex::operator+ (const Real &) const
2.Kdy se zavola na globalni promenne konstrukor?
A. Pro globalni promenne neni povolen udelat konstruktor
B. Pri kompilaci
C. Pred vstupem do main [X]
D. Na globalni fce neni treba volat konstruktor.
3.
Kód: Vybrat vše
namespace T {
double f(char x);
};
namespace U {
char f(double d);
};
int f(int i);
using namespace T;
using namespace U;
char x = f('A');
A. T::f(char) [X]
B. U::f(int)
C. nelegalni volani
D. U::f(double)
4.
Kód: Vybrat vše
Class U {
U() {a = 1}
U(int i) {a= i + 2}
int a
}
Class T: public U {
T() : U(2) {}
T(int i) {a = a + 3}
T(T &p) {}
}
T x = U();
A.4
B.3[X] - teda myslim, ja dal 4 a bylo to spatne
C.5
D.1
5. Jaky by mel byt konstruktor abstraktni tridy?
A.private
B.public
C.protected[X]
D.zaden
6.
Kód: Vybrat vše
class A{
public: virtual f();}
class B{
public: virtual f();}
B b;
A a=b;
a.f().
A.A::f() [X]
B.B::f()
C.konstrukce vyvola vyjimku
7.
Kód: Vybrat vše
class Complex{
public:
double Re, Im;
complex(Re=0.0, Im=0.0):complex(Re, Im);
complex operator+(complex &);
}
complex complex::operator+(complex & b){
double r = Re + b.Re;
double i = Im + b.Im;
???;
}
A. return complex(r,i); [X]
B. return (r,i);
C. return * new complex(r,i);
D. return new complex (r,i);
8. Ve kterych radcich to hodi chybu
Kód: Vybrat vše
f(std::vector<int> v){
1. std::vector<int>::iterator it;
2. std::find(v.begin(), v.end(), 0);
3. it = v.insert(it, -1);
4. v.insert(it+2, 1);}
9. mame implementovany Stack, a metodu push
Kód: Vybrat vše
class SStk {
public:
/* ... */
void push(const std::string & s);
private:
std::string * p_;
int allocated_, used_;
};
void SStk::push (const std::string & s) {
if (used_ >= allocated) {
int n2 = (allocated_ +1) * 2;
[X] std::string * p2 = new string[n2];
for(int i = 0; i < used_; ++i)
[X] p_[i] = p2[i];
delete[] p2;
p_ = p2;
allocated_ = n2;
}
[X] p_[used_] = s;
++used_;
}
10. pokud se vyskytne vyjimka co se s konzistentnim stackem stane?
A. Zanecha zasobnik v nezmenenem stavu
B. Muze zposobit ztratu (nedostupnost) alokovane pamete [X]
C. Muze zanechat zasobnik v nekonzistentnim stavu, ktery muze (pozdeji) zpusobit behovou chybu [X]
Takze asi tak...enjoy...to byla jen jedna varianta...chce to i dalsi varianty. Tak se cinte...jiank muj vysledek...nenechal jsme si to zapsat...zkopal jsme to....