File tree 1 file changed +50
-0
lines changed 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ Source & Header
3
+
4
+ The header file (.h) holds the function declarations (prototypes) and variable declarations.
5
+ It currently includes a template for our new MyClass class, with one default constructor.
6
+ MyClass.h
7
+ */
8
+
9
+ #include <iostream>
10
+ using namespace std;
11
+
12
+ #ifndef MYCLASS_H
13
+ #define MYCLASS_H
14
+
15
+ class MyClass
16
+ {
17
+ public:
18
+ MyClass();
19
+ protected:
20
+ private:
21
+ };
22
+
23
+ #endif // MYCLASS_H
24
+
25
+ int main() {
26
+ return 0;
27
+ }
28
+
29
+ /*
30
+ The implementation of the class and its methods go into the source file (.cpp).
31
+ Currently it includes just an empty constructor.
32
+ MyClass.cpp
33
+ */
34
+
35
+ #include "MyClass.h"
36
+
37
+ MyClass::MyClass()
38
+ {
39
+ //ctor
40
+ }
41
+ /* 1- In header file, You declare all of the class functions and variables. You determine which one is public, protected or private.
42
+
43
+ 2- In source file, You write the function body and use the variables you declared in header.
44
+
45
+ 3- You will learn about Scope operator (::) in the following lessons.
46
+ Only note that it is an operator for recalling constructors (and every other functions) of a class in source file.
47
+ Source = .cpp file
48
+ Header = .h file
49
+ Source != Header
50
+ */
You can’t perform that action at this time.
0 commit comments