Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by Ayush ( 7 years ago )
#include <iostream>
using namespace std;

class Base{
	protected:
	int x, y;
	public:
	Base(){ x = y = 0; cout << "Base 0: " << "x = " << x << ", y = " << y << endl;}
	Base(int a){ x = y = a; cout << "Base 1: " << "x = " << x << ", y = " << y << endl;}
	Base(int b, int c){ x = b; y = c; cout << "Base 2: " << "x = " << x << ", y = " << y << endl;}
};

class Derived:public Base{
	private:
	int l, m;
	public:
	Derived(){ l = m = 0; cout << "Derived 0: " << "l = " << l << ", m = " << m << endl << endl;}
	Derived(int d):Base(d){ l = m = d; cout << "Derived 1: " << "l = " << l << ", m = " << m << endl << endl;}
	Derived(int e, int f):Base(e, f){ l = e; m = f; cout << "Derived 2: " << "l = " << l << ", m = " << m << endl << endl;}
	Derived(int g, int h, int i):Base(g, h){ l = m = i; cout << "Derived 3: " << "l = " << l << ", m = " << m << endl << endl;}
	Derived(int p, int q, int r, int s):Base(p, q){ l = r, m = s; cout << "Derived 4: " << ", l = " << l << ", m = " << m << endl << endl;} 
};

int main(){
	Derived D0;
	Derived D1(10);
	Derived D2(20,30);
	Derived D3(40,50,60);
	Derived D4(70,80,90,100);
}

 

Revise this Paste

Your Name: Code Language: