We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c0e1612 + ba2c827 commit 9b5c9eeCopy full SHA for 9b5c9ee
OOPs/Constructor/Parameterized_Constructor_cpp.cpp
@@ -0,0 +1,30 @@
1
+// C++ program to demonstrate Parameterized Constructor
2
+
3
+// Parameterized Constructor - A constructor which has parameters is known as Parameterized Constructor. It is
4
+// used to provide different values to distinct objects.
5
6
+#include<bits/stdc++.h>
7
+using namespace std;
8
9
+// class with Parameterized Constructor
10
+class Person{
11
+ private:
12
+ string name;
13
+ int age;
14
+ public:
15
+ Person(string iname,int iage){
16
+ name=iname;
17
+ age=iage;
18
+ }
19
+ void display(){
20
+ cout<<"Name : "<<name<<endl;
21
+ cout<<"Age : "<<age<<endl;
22
23
+};
24
25
+int main(){
26
+ // Creating an object of class Person
27
+ Person p("abc",10);
28
+ p.display();
29
+ return 0;
30
+}
0 commit comments