pridani poznamek s conteinery, restrukturalizace, oprava kodu

pridani poznamek ke containerum zatim pouze s vectory
poznamky z hodim maji ted vlastni podslozku
lehka oprava kodu vsede mozne, hlavne pridani cpp pro lepsi cteni a
oprava drobnych chybek
This commit is contained in:
2026-03-06 15:30:21 +01:00
parent c2bedb027e
commit 56b536368b
3 changed files with 214 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
- 26. 2 - čtvrtek 11:00
- dnes: třídy a objekty, public/protected/private, constructor/destructor
# Konstruktory
- můžu přetěžovat, ale **POZOR**:
```
TridaA(void) //constructor pro inicializaci promenne
{
this->a = 0;
this->b = 0;
this->c = 0;
std::cout << "Byl zavolan konstruktor bez arg." << std::endl;
}
TridaA(int a) //inicializace z argumentu constructoru
{
this->a = a;
this->b = 0;
this->c = 0;
std::cout << "Byl zavolan konstruktor s arg." << std::endl;
}
TridaA(int a, int b = 42, int c = 64)
{
this->a = a;
this->b = b;
this->c = c;
}
```
Chyby kompilatoru:
```
main.cpp: In function int main():
main.cpp:44:16: error: call of overloaded TridaA(int) is ambiguous
44 | TridaA obj1(1); //inicializujeme objekt
| ^
main.cpp:44:16: note: there are 4 candidates
main.cpp:31:5: note: candidate 1: TridaA::TridaA(int, int, int)
31 | TridaA(int a, int b = 42, int c = 64)
| ^~~~~~
main.cpp:23:5: note: candidate 2: TridaA::TridaA(int)
23 | TridaA(int a) //inicializace z argumentu constructoru
| ^~~~~~
main.cpp:3:7: note: candidate 3: constexpr TridaA::TridaA(const TridaA&)
3 | class TridaA
| ^~~~~~
main.cpp:3:7: note: candidate 4: constexpr TridaA::TridaA(TridaA&&)
```
- **MUSÍ TO BÝT JEDNOZNAČNÉ:**