1. Mavzu. Rekursiv jarayonlarni tashkil etish O’zbekiston respublikasi


Download 18.88 Kb.
bet7/9
Sana13.11.2023
Hajmi18.88 Kb.
#1769541
1   2   3   4   5   6   7   8   9
Bog'liq
1. Mavzu. Rekursiv jarayonlarni tashkil etish-hozir.org (2)

Konstruktor nomi sinf nomi bilan bir xil bo‘lishi lozimdir. Misol uchun siz employee sinfdan foydalansangiz, konstruktor ham employee nomga ega bo‘ladi. Agar dasturda konstruktor ta’rifi berilgan bo‘lsa ob’ekt yaratilganda avtomatik chaqiriladi. Quyidagi dasturda employee nomli sinf kiritilgandir:

class employee

{ public:

employee(long, float);

void show_employee(void);

private: long employee_id;

float salary; };

Konstruktor ta’rifi:

employee::employee(long empl_id, float sal)

{employee_id = empl_id; if (salary < 50000.0)

salary = sal;

Else salary = 0.0; }

Shu sinfdan foydalanilgan dastur:

#include

using namespace std;

class employee

{ public: employee(long, float);

void show_employee(void);

private: long employee_id;

float salary;

}; employee::employee(long empl_id, float sal)

{ employee_id = empl_id;

if (salary < 50000.0) salary = sal;

Else salary = 0.0;

} void employee::show_employee(void)

{ cout << "Nomer: " << employee_id << endl;

cout << "Maosh: " << salary << endl;

}

int main()

{

employee worker(101, 10101.0);

cout<<"ishchi"<

worker.show_employee();

return 0;

}

Konstruktordan foydalanib ob’ekt ta’rifilanganda parametr uzatish mumkin: employee worker(101, 10101.0);

Agar dasturda employee tipidagi ob’ektlar mavjud bo‘lsa har birini quyidagicha initsializatsiya qilish mumkin

employee worker(101, 10101.0);

employee secretary(57, 20000.0);

employee manager(1022, 30000.0);

5.Mavzu.Abstrakt sinflarni tashkil etish.

Serial Key Generator foydalanuvchini ushbu kalitni yaratishda ishtirok etadigan belgilarni sozlashni taklif qiladi. Masalan, siz faqat katta yoki kichik harflarni ko'rsatishingiz, shuningdek raqamlarni qo'shishingiz yoki olib tashlashingiz mumkin. Bundan tashqari, bitta koddagi ustunlar soni va ulardagi belgilar soni sozlangan.


Download 18.88 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling