Skip to content

Commit 04ffa90

Browse files
committed
advance classes
1 parent 88dd626 commit 04ffa90

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

Diff for: classes/advance-class-helloworld.cpp

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* this is an extra step in classes
3+
*/
4+
5+
6+
// importing iostream header file :)
7+
#include <iostream>
8+
9+
/**
10+
* creating a class named myClass
11+
*/
12+
13+
class myClass {
14+
public:
15+
void helloworld()
16+
{
17+
std::cout << "hello world\n";
18+
};
19+
};
20+
21+
/**
22+
* calling it in another void function
23+
* for imporiving code clean
24+
*/
25+
26+
void callbackfunction()
27+
{
28+
myClass myObj;
29+
30+
myObj.helloworld();
31+
}
32+
33+
/**
34+
* calling the callbackfunction using a simple if loop
35+
*/
36+
37+
int main()
38+
{
39+
int x = 10;
40+
41+
if (x == 10) {
42+
callbackfunction();
43+
} else {
44+
std::cout << "oops i cant get the class ;(\n";
45+
}
46+
47+
return 0;
48+
}

0 commit comments

Comments
 (0)