Click here to load reader

Klase u c++

  • View
    126

  • Download
    3

Embed Size (px)

Text of Klase u c++

SADRAJ1. Uvod u programski jezik C++ 1. 2. 3. 4. 5.Programski jezik C++ ............................................................................................ 9 Turbo C++ 2006 ......................................................................................................9 Prvi C++ program ............................................................................................... 12 Stil i forma pisanja C++ programa .................................................................15 Komentari u programu ...................................................................................... 16

2. Varijable i konstante 1. Uvod.......................................................................................................................... 19 2. Int (Cjelobrojni tip) ............................................................................................ 19 3. Float (Realni tip).................................................................................................... 20 4. Char (Znakovni tip)............................................................................................. 24 5. Imenovane konstante i typedef deklaracija .............................................. 24 6. Enum konstante, long i double tipovi podataka .................................... 25 7. Kvalifikatori short, signed i signed................................................................. 26 8. Cast i sizeof operatori ....................................................................................... 27 9. Aritmetiki operatori ......................................................................................... 28 10. Dodjela vrijednosti izrazima............................................................................ 30 11. Strukture i unije podataka................................................................................ 32 3. Naredbe za ispis i unos podataka 1. 2. 3. 4.Naredbe cout i cin .............................................................................................. 37 Naredbe printf i scanf ...................................................................................... 42 Ispis i unos podataka - Dodatak..................................................................... 47 Pretvorbe tipova podataka ............................................................................. 50

4. Naredbe za grananje 1. 2. 3. 4. 5.Uvod ........................................................................................................................ 53 Relacijski i logiki operatori ............................................................................ 53 Naredba if ............................................................................................................... 55 Uvjetni operator ?................................................................................................. 59 Naredba switch .................................................................................................... 60

3

5. Programske petlje 1. 2. 3. 4. 5. 6.Uvod.......................................................................................................................... 64 Petlja for .................................................................................................................. 64 Petlja while .............................................................................................................69 Petlja do-while ...................................................................................................... 70 Naredbe break i continue ................................................................................. 72 Naredba goto ........................................................................................................78

6. Polja i pokazivai 1. 2. 3. 4. 5. 6.Jedno i viedimenzionalna polja ................................................................... 76 Rad sa znakovima i znakovnim poljima ......................................................82 Sortiranje polja ..................................................................................................... 85 Pokazivai i reference ......................................................................................... 88 Dinamika alokacija i realokacija memorije ...............................................92 Pokazivai na pokazivae ................................................................................. 96

7. Funkcije i pretprocesorske naredbe 1. Uvod.......................................................................................................................... 99 2. Funkcija kao blok naredbi ................................................................................ 99 3. Primjene funkcija ...............................................................................................101 4. Funkcije i pokazivai ........................................................................................ 105 5. Statike varijable funkcije .............................................................................. 110 6. Funkcija main( ) ................................................................................................. 111 7. Rekurzije................................................................................................................ 113 8. Lista argumenata funkcije ............................................................................. 115 9. Podrazumijevani parametri funkcije .......................................................... 117 10. Konstantni argumenti funkcije .................................................................... 118 11. Pretprocesorske naredbe ............................................................................... 118 8. Rad sa datotekama 1. 2. 3. 4. 5.Uvod ........................................................................................................................... Datoteke i C++ ........................................................................................................ Naredbe fscanf, fprintf... ...................................................................................... Neformatirane datoteke ....................................................................................... Zatita podataka .....................................................................................................

9. Strukture i liste 1. Uvod ........................................................................................................................... 4

2. STOG realiziran poljem ........................................................................................ 3. STOG realiziran listom ........................................................................................... 4. Red realiziran ciklikim poljem ......................................................................... 5. Red realiziran listom .............................................................................................. 6. Sortirane i viestruko povezane liste ............................................................... 7. Binarno pretraivanje ............................................................................................ 10. Uvod u klase

1. 2. 3. 4. 5. 6. 7. 8. 9.11.

Uvod ............................................................................................................................ Konstrukcija klase ................................................................................................... Preoptereenje funkcije ....................................................................................... Funkcije prijatelji ..................................................................................................... Operatorske funkcije ............................................................................................. Statiki lanovi klase .............................................................................................. Nasljeivanje klasa ................................................................................................. Virtualne funkcije .................................................................................................... Predloci ....................................................................................................................

Sigurnosne pretvorbe i iznimke

1. 2. 3. 4. 5. 6. 7. 8. 9. 12.

Uvod ............................................................................................................................ Pretvorba static_cast ............................................................................................. Pretvorba dynamic_cast ...................................................................................... Pretvorba reinterpret_cast .................................................................................. Pretvorba const_cast ............................................................................................. Generiranje i obrada iznimki ............................................................................. Standardne iznimke ............................................................................................... Neprihvaene iznimke .......................................................................................... Funkcije i iznimke ..................................................................................................

Kontrolne klase

1. Uvod ........................................................................................................................... 2. Klase TButton, TRadioButton i TGroupBox ..................................................... 3. Klase TCheckBox, TStatic i TGauge .................................................................... 4. Klase TSlider i TScrollBar .................................

Search related