Modül 16 - Inheritance (Kalıtım)

Constructor Zinciri

C++ Programlama Eğitimi · 1 görev

# Constructor Zinciri

Bir nesne oluşturulduğunda önce Base Class constructor'ı, ardından Derived Class constructor'ı çalışır.

Bu işlem otomatik olarak gerçekleşir.

Örnek Kod
#include <iostream>
using namespace std;

class A
{
public:
    A(){ cout << "A Constructor" << endl; }
};

class B : public A
{
public:
    B(){ cout << "B Constructor" << endl; }
};

int main()
{
    B obj;
}

🎯 Bu Dersteki Görevler

Constructor Sırası

Dil: cpp

Yükleniyor…