Ad Code

Responsive Advertisement

parameterized constructor in c++








programs of parameterized constructor :

#include<iostream>
using namespace std;
class abc{
	int a,b;
	public:
	abc(int a1){
		a=a1;
	}
	abc(int a1,int a2){
		a=a1;
		b=a2;
		cout<<"two parameter is called";
	}
	int get_a(){
		return a;
	}
	int get_b(){
		return b;
	}
};
int main(){
	abc st(10,20);
	cout<<st.get_a();
	cout<<st.get_b();
}



out put:
 two parameter is called
 10
 20



If you like code with vibhu  and would like to contribute, you can also write an article using   This link :

https://docs.google.com/forms/d/e/1FAIpQLScAmvlPvNUz35R-G0nc_zpRVP3o8xlhtFgC3aKPyLetX_RyXg/viewform?pli=1


OR  mail your article to bibhutiswain990@gmail.com.  See your article appearing on the code with vibhu main page and help other students. 

Post a Comment

0 Comments