We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent baff4ca commit 9769197Copy full SHA for 9769197
ClassesInsideFunctions.cpp
@@ -0,0 +1,35 @@
1
+#include<iostream>
2
+
3
+using namespace std;
4
5
+//Implementation of Local classes-Classes defined inside a function
6
7
+//function prototyping-forward declaration
8
+void getClass();
9
10
+int main(){
11
+ getClass();
12
+ return 0;
13
14
+}
15
16
17
+void getClass() {
18
+ class Person {
19
+ public:
20
+ string name;
21
+ int age;
22
+ void getdetails() {
23
24
+ cout<<"Name: "<<name<<endl<<"Age is :"<<age<<endl;
25
+ }
26
+ };
27
28
+ //Class object and the members of class can only be used inside the function as it has a local block scope
29
+ Person p;
30
+ p.name="Anish";
31
+ p.age=20;
32
+ p.getdetails();
33
34
35
0 commit comments