C++ code samples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
class MojeExcept : public std::logic_error{
public:
MojeExcept() : logic_error("Moje vyjimka!"){};
};
typedef struct Oddeleni
{
int cislo;
std::string nazev;
bool operator==(const Oddeleni &odd){
if (this->cislo == odd.cislo)
{
return true;
}
return false;
}
bool operator!=(const Oddeleni &odd){
if (this->cislo != odd.cislo)
{
return true;
}
return false;
}
bool operator>(const Oddeleni &odd)const
{
if (this->cislo > odd.cislo)
{
return true;
}
return false;
}
bool operator<(const Oddeleni &odd)const
{
if (this->cislo < odd.cislo)
{
return true;
}
return false;
}
}tOddeleni;
typedef struct Zamestnanec{
int cislo;
std::string jmeno;
};
struct Kopir
{
bool operator()(std::pair<Oddeleni, Zamestnanec> odd)
{
if (odd.first.cislo == 1)
{
return true;
}
return false;
}
};
void PridejZamestnance(Zamestnanec z,Oddeleni o)throw(MojeExcept)
{
for (std::vector<Oddeleni>::iterator i = odd->begin(); i != odd->end(); ++i)
{
if (*i == o)
{
db->insert(std::pair<Oddeleni, Zamestnanec>(o, z));
cout << "Zamestnanec vlozen.\n";
return;
}
}
throw MojeExcept();
}
ostream& operator<<(ostream &s, const tabulka t)
{
string str;
str = "Tabulka:\n";
for (int i = 0; i < t.rad; i++)
{
for (int j = 0; j < t.sl; j++)
{
str += to_string(t.tab[i][j]);
str += "\t";
}
str += "\n";
}
return s << str;
}
void Napln()
{
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
tabulka[i][j] = i + j;
}
}
}
|
1 2 3 4 5 6
|
/* if (this->cislo == odd.cislo)
{
return true;
}
return false;*/
return this->cislo == odd.cislo;
|
comment your code
Topic archived. No new replies allowed.