- Page 1 and 2:
Programowanie w C i C++ BORLAND C++
- Page 3 and 4:
Lekcja 1. Co o C i C++ każdy wiedz
- Page 5 and 6:
Nauczywszy się języka C/C++ może
- Page 7 and 8:
upodobania) * nazwy stałych (gdyby
- Page 9 and 10:
Zaczynamy zatem od rzeczy najprosts
- Page 11 and 12:
Program instalacyjny utworzy na wsk
- Page 13 and 14:
___________________________________
- Page 15 and 16:
LEKCJA 3. Główne menu i inne elem
- Page 17 and 18:
[Shift]-[Tab] (spróbuj!). Możesz
- Page 19 and 20:
[Alt]+[R] menu Run (Uruchamianie) [
- Page 21 and 22:
JAK STĄD WYJŚĆ ? Aby zapisać pl
- Page 23 and 24:
2. Przejść do odpowiedniego katal
- Page 25 and 26:
LEKCJA 4. Jeszcze o IDE C++ . _____
- Page 27 and 28:
[Alt]-[F3]. _______________________
- Page 29 and 30:
Ten rozkaz pozwala Ci ustawić konf
- Page 31 and 32:
Jeśli korzystasz z programu Norton
- Page 33 and 34:
W ten sposób C++ ZNOWU chce Cię u
- Page 35 and 36:
LEKCJA 5. DZIAŁANIA PRZY POMOCY MY
- Page 37 and 38:
[S] Entry Point ___________________
- Page 39 and 40:
to specjalne słowo wchodzące w sk
- Page 41 and 42:
#include Takie specjalne linie (zw
- Page 43 and 44:
LEKCJA 6. NASTĘPNY PROGRAM - KOMPU
- Page 45 and 46:
eturn - słowo kluczowe: Powrót, z
- Page 47 and 48:
Zwróć uwagę, że to randomize()
- Page 49 and 50:
UWAGA: MUSI ZOSTAĆ ZACHOWANA IDEAL
- Page 51 and 52:
zauważysz łańcuchy znaków pisan
- Page 53 and 54:
exit() - wyjście. ________________
- Page 55 and 56:
domyślnych ustawieniach kompilator
- Page 57 and 58:
ponieważ format "%s" jest formatem
- Page 59 and 60:
komentarza. Zwróć uwagę, że fun
- Page 61 and 62:
6. Powtórzyć kompilację programu
- Page 63 and 64:
angielskiego (swoją drogą, może
- Page 65 and 66:
sizeof - podaj wielkość. static -
- Page 67 and 68:
pliku nagłówkowym IOSTREAM.H) poz
- Page 69 and 70:
stdout jest skrótem od Standard Ou
- Page 71 and 72:
klasy, zadania skomplikowały się:
- Page 73 and 74:
itp...(szczegóły - patrz niżej).
- Page 75 and 76:
cin >> x; cout
- Page 77 and 78:
Operator >> pobiera ze strumienia d
- Page 79 and 80:
int main(void) { clrscr(); printf("
- Page 81 and 82:
€€€€€Kreska "/" nazywa si
- Page 83 and 84:
printf("Wydrukuje A jako \nLiteral
- Page 85 and 86:
Nasz program mógłby przy zastosow
- Page 87 and 88:
[P016.CPP] // Przyklad FACELIFT.CPP
- Page 89 and 90:
LEKCJA 10. Jakie operatory stosuje
- Page 91 and 92:
----------|--------------|---------
- Page 93 and 94:
[P017.CPP ] // UNARY.CPP - operator
- Page 95 and 96:
* INSTRUKCJĘ WARUNKOWĄ: if (KLAWI
- Page 97 and 98:
Zapraszamy teraz debugger do pracy
- Page 99 and 100:
LEKCJA 11. Jak deklarować zmienne.
- Page 101 and 102:
W powyższych przykładach zwróć
- Page 103 and 104:
sam efekt, jak zastosowanie kompila
- Page 105 and 106:
stosowaliśmy - funkcji wejścia -
- Page 107 and 108:
przypisuje wskaźnikowi px adres zm
- Page 109 and 110:
Zwróć uwagę, że kolejność {L
- Page 111 and 112:
77€€€€€€€€€€€
- Page 113 and 114:
element) tablicy; - samą tablicę;
- Page 115 and 116:
char hej[5]="Ahoj"; char hej[5]={'A
- Page 117 and 118:
} printf("Suma wynosi: %d\n", suma)
- Page 119 and 120:
{31,32,33,34,35,36},{41,42,43,44,45
- Page 121 and 122:
} printf("\n"); } printf("\n Inicju
- Page 123 and 124:
1. Posługując się wskaźnikiem i
- Page 125 and 126:
Instrukcja może być INSTRUKCJĄ G
- Page 127 and 128:
const float d=1.2345; void main() {
- Page 129 and 130:
cout
- Page 131 and 132:
if (Wyrażenie) Instrukcja; if (Wyr
- Page 133 and 134:
przypadków - wariantów (case). Ka
- Page 135 and 136:
printf("%f", wynik); } INSTRUKCJA S
- Page 137 and 138:
LEKCJA 14. Jak tworzyć i stosować
- Page 139 and 140:
int wiek; char pokrewienstwo[10] };
- Page 141 and 142:
* deklarację jednowymiarowej tabli
- Page 143 and 144:
Rozszyfrujmy zapis: strcpy(Pointer-
- Page 145 and 146:
struct { unsigned pole_I:4; unsigne
- Page 147 and 148:
LEKCJA 15. Jak posługiwać się fu
- Page 149 and 150:
np: itoa() - Integer TO Ascii - zam
- Page 151 and 152:
cos() - cosinus, sin() - sinus, tan
- Page 153 and 154:
eturn 0; } double FUNKCJA(double X,
- Page 155 and 156:
{ int Zmienna; clrscr(); Zmienna =
- Page 157 and 158:
W linii /* DZIALANIE */ mnożymy i
- Page 159 and 160:
[P051.CPP] int BALAGAN[10]; int POR
- Page 161 and 162:
choćby, opisu pomijanego dyskretni
- Page 163 and 164:
3 Spróbuj przeprowadzić rzutowani
- Page 165 and 166:
Umieściliśmy w pamięci łańcuch
- Page 167 and 168:
ADD DX, '0' ;Dodaj kod ASCII "zera"
- Page 169 and 170:
stanie się 0. Czy można jednakże
- Page 171 and 172:
cin >> x >> y; cout
- Page 173 and 174:
"pozostawia" argumenty przeznaczone
- Page 175 and 176:
LEKCJA 17. TROCHĘ SZCZEGÓLÓW TEC
- Page 177 and 178:
postaci 00 00 60 40. Rozpatrzmy szk
- Page 179 and 180:
} return (_AX); } //Zwróć zawarto
- Page 181 and 182:
hex) wykorzystuje DOS i Basic. Wekt
- Page 183 and 184:
# include void InstalujWektor(void
- Page 185 and 186:
SI -> 0...31 ESI w tym (SI = 0..15)
- Page 187 and 188:
LEKCJA 18. O ŁAŃCUCHACH TEKSTOWYC
- Page 189 and 190:
funkcję: strcat() - STRing conCATe
- Page 191 and 192:
łańcucha pozwala mieć pewność,
- Page 193 and 194:
W tym przykładzie wywołujemy funk
- Page 195 and 196:
wprowadzać napisów zawierających
- Page 197 and 198:
wyszukanego pierwszego wystąpienia
- Page 199 and 200:
LEKCJA 19: KILKA INNYCH PRZYDATNYCH
- Page 201 and 202:
STD STD OUTput - standardowe wyjśc
- Page 203 and 204:
* zamknięcie pliku; * otwarcie pli
- Page 205 and 206:
LEKCJA 20. JEŚLI PROGRAM POWINIEN
- Page 207 and 208:
void main() { printf("Wyjscie do DO
- Page 209 and 210:
* Inkrementuj licznik */ for (; lic
- Page 211 and 212:
licznik++; licznik %= 10; ekran[0][
- Page 213 and 214:
void main() { char nazwapliku[40];
- Page 215 and 216:
LEKCJA 21: KILKA PROCESÓW JEDNOCZE
- Page 217 and 218:
proces1(); proces2(); return 0; } A
- Page 219 and 220:
while(kbhit()) { gotoxy(1,1); print
- Page 221 and 222:
longjmp(bufor2,2); } } Procesy odby
- Page 223 and 224:
powrocie z procesu identyfikować -
- Page 225 and 226:
LEKCJA 22. NA ZDROWY CHŁOPSKI ROZU
- Page 227 and 228:
zadziała szybciej niż for(j = 1;
- Page 229 and 230:
MAX || W1 || W2 || W3 ... MIN && W1
- Page 231 and 232:
stosując zamiast if-else operator
- Page 233 and 234:
LEKCJA 23. Co nowego w C++? _______
- Page 235 and 236:
C++ pozwala deklarować zmienne w d
- Page 237 and 238:
switch (n) { case niewymowne: cout
- Page 239 and 240:
W programie przykładowym funkcje z
- Page 241 and 242:
W obszarze kodu (I.) znajdują się
- Page 243 and 244:
int *pointer = new int[3]; // Przyd
- Page 245 and 246:
for (i = 0; i < ilosc; i++) cout i
- Page 247 and 248:
cout > Liczba; cout
- Page 249 and 250:
LEKCJA 24. SKĄD WZIĘŁY SIĘ KLAS
- Page 251 and 252:
Data::Data(void) { dzien = 3; miesi
- Page 253 and 254:
int ODDAJ(void); }; void Zwierzak::
- Page 255 and 256:
Klasy służą do tworzenia formaln
- Page 257 and 258:
public: int dane; void Inicjuj(void
- Page 259 and 260:
{ ... Obiekt.dane = 5; Obiekt.Inicj
- Page 261 and 262:
Aby funkcja inicjująca pole strukt
- Page 263 and 264:
obiekt. Zawartość naszego obiektu
- Page 265 and 266:
{ return znak; } Ten sam problem wy
- Page 267 and 268:
LEKCJA 26. CO TO JEST KONSTRUKTOR.
- Page 269 and 270:
{ ... } main() { Licznik licznik('A
- Page 271 and 272:
[P095.CPP] /* Wersja z klasą i obi
- Page 273 and 274:
ozmieszczenie 50 liczb typu int (po
- Page 275 and 276:
cout
- Page 277 and 278:
{ if(licznik >= 49) return 0; else
- Page 279 and 280:
dzis.rok = 1900 + tim.tm_year; cout
- Page 281 and 282:
{ private: Lista danych i funkcji p
- Page 283 and 284:
należącymi do obu typów struktur
- Page 285 and 286:
} Można dziedziczyć po więcej ni
- Page 287 and 288:
Pamiętając o problemie domyślneg
- Page 289 and 290:
class ZNAK { char znak_dany; public
- Page 291 and 292:
} Obiekt.Znikaj(); getch(); Obiekt.
- Page 293 and 294:
} Łańcuch znaków jest widziany j
- Page 295 and 296:
kluczowego "inline" w definicjach f
- Page 297 and 298:
for(int i = 1; i < ile; i++) cout
- Page 299 and 300:
LEKCJA 30. WYMIANA DANYCH MIĘDZY O
- Page 301 and 302:
[P107.CPP] # include //prototyp to
- Page 303 and 304:
kluczowego friend. A oto definicja:
- Page 305 and 306:
{ } ile++; //Wiadomo o ktory obiekt
- Page 307 and 308:
{ public: char moja_litera; static
- Page 309 and 310:
ile++; } void Licznik::Pokazuj(void
- Page 311 and 312:
ędzie wyglądać tak: Pokazuj(licz
- Page 313 and 314:
Programy manipulujące obiektami w
- Page 315 and 316:
{ int zmienna; int& ksywa; ... Aby
- Page 317 and 318:
Zmienna (ADR-hex) Ksywa (ADR-hex):
- Page 319 and 320:
void Skok_licznika(void) { ile++; }
- Page 321 and 322:
LEKCJA 33. OVERLOADING OPERATORÓW.
- Page 323 and 324:
Zaczniemy od operatora + należące
- Page 325 and 326:
nowadata = staradata + 14; zostanie
- Page 327 and 328:
static int TAB[] = {31,28,31,30,31,
- Page 329 and 330:
z = x + y; Dodajemy dwa obiekty x i
- Page 331 and 332:
cout
- Page 333 and 334:
{ public: long wartosc; Liczba(int
- Page 335 and 336:
overloadingowi operator
- Page 337 and 338:
main() { Cpochodna Obiekt(...); ...
- Page 339 and 340:
char imie[30]; public: void Oddycha
- Page 341 and 342:
Taki efekt nazywa się polimorfizme
- Page 343 and 344:
LEKCJA 35. FUNKCJE WIRTUALNE i KLAS
- Page 345 and 346:
} W tym pokoleniu definicja wirtual
- Page 347 and 348: zgłoszenie na ekranie. class CA {
- Page 349 and 350: }; main() { CB Obiekt; return 0; }
- Page 351 and 352: LEKCJA 36. KAŹDY DYSK JEST ZA MAŁ
- Page 353 and 354: } #define ILE (1024*640) near unsig
- Page 355 and 356: printf("\nKropka [.] = Quit"); prin
- Page 357 and 358: danych na ekran monitora różnymi
- Page 359 and 360: TAK!. W BORLAND C++ 3+ ... 4+ wysta
- Page 361 and 362: Skoro ustawiliśmy już poprawnie n
- Page 363 and 364: wyposażone w: - Pasek z tytułem (
- Page 365 and 366: * Jeśli korzystamy wyłącznie ze
- Page 367 and 368: * WIN2.CPP: */ /* - Tablica dwuwymi
- Page 369 and 370: wpisujemy 0 LPCSTR lpszText - dalek
- Page 371 and 372: oznacza umieszczenie ikony STOP i k
- Page 373 and 374: { p2 = &napisy[i][0]; strcat(p0, p2
- Page 375 and 376: ID_... MB_... - IDentifier - IDenty
- Page 377 and 378: FUNKCJE WinMain() i WindowProc(). W
- Page 379 and 380: case WM_SETFOCUS: SetFocus(hEditWnd
- Page 381 and 382: WinMain(). Windows manipulują komu
- Page 383 and 384: ysować własnego okna. [Z] _______
- Page 385 and 386: .... break; case WM_SIZE: .... brea
- Page 387 and 388: Funkcja MainWin() rejestruje i twor
- Page 389 and 390: { case WM_CREATE: Gdy okno jest two
- Page 391 and 392: if (!RegisterClass(&wndclass)) retu
- Page 393 and 394: Options | Compiler | Code generatio
- Page 395 and 396: TextOut(NrKontekstu, 100, 250, "!KO
- Page 397: case WM_PAINT: hDC = BeginPaint(hWn
- Page 401 and 402: LEKCJA 42. Elementy sterujące i za
- Page 403 and 404: Zdarzenie w oknie elementu sterują
- Page 405 and 406: { switch(Message) { case ID_EDIT: i
- Page 407 and 408: hWnd, ID_Elem, hInstance, 0); Ident
- Page 409 and 410: wndClass.hCursor= LoadCursor(NULL,
- Page 411 and 412: LEKCJA 43. O Okienkach dialogowych.
- Page 413 and 414: wndClass.hbrBackground= GetStockObj
- Page 415 and 416: ___________________________________
- Page 417 and 418: przypisać odpowiedniemu polu struk
- Page 419 and 420: Usuwanie pozycji z menu można prze
- Page 421 and 422: BEGIN POPUP "&File" BEGIN MENUITEM
- Page 423 and 424: LEKCJA 45. O PROGRAMACH OBIEKTOWO -
- Page 425 and 426: } A oto pętla pobierania komunikat
- Page 427 and 428: if (Scroller && sizeType != SIZE_MI
- Page 429 and 430: wpisujemy zero, ponieważ program n
- Page 431 and 432: (Engine). Rozważmy to na przykład
- Page 433 and 434: ___________________________________
- Page 435 and 436: } Jeśli wybrano klawisz [Yes] funk
- Page 437 and 438: Gotowe "klocki" można wykorzystać
- Page 439 and 440: { return (MessageBox(HWindow, Ptr,
- Page 441 and 442: klawiszami [Print Screen] \ lub [Al
- Page 443 and 444: LEKCJA 47. O PAKIETACH BORLAND C++
- Page 445 and 446: W skład pakietu wchodzą między i
- Page 447 and 448: - inną bibliotekę Runtime Library
- Page 449:
pozostał Ci już tylko wykonanie t