Constructor Overloading
# Constructor Overloading
Bir class içerisinde aynı isimde birden fazla constructor bulunabilir.
Buna Constructor Overloading denir.
Parametre sayısı veya veri tipleri farklı olduğu sürece birden fazla constructor tanımlanabilir.
Bu yöntem farklı şekillerde nesne oluşturmayı sağlar.
Örnek Kod
#include <iostream>
using namespace std;
class Product
{
public:
Product()
{
cout << "Bos constructor" << endl;
}
Product(int id)
{
cout << "ID: " << id;
}
};🎯 Bu Dersteki Görevler
Overloading
Dil: cpp
Yükleniyor…