+ 2

Is it possible to declare AND define classes in ONE header file?

Do we really need to create header and source files for all classes or can the declaration/defination be in one file?

6th Jul 2016, 6:17 PM
Christian Roos
Christian Roos - avatar
5 odpowiedzi
+ 3
Yeah agree. And when you define functions in the header file they become automatically inline. That means these functions work faster than the ones defined separately. It is a good practice to define setters and getters in the header since they are used to access data and it will be fast
7th Jul 2016, 4:34 AM
Sardor
Sardor - avatar
+ 1
Yes.. you can... mainly when you import a header what you are doing is like copy and pasting the code inside the header in the beginnig of your main code file where you called the import command... but the idea behind headers is that your code its no exposed to the user... just the class, methods, properties and fuction names.. you can pack your code in a dll format or someting similar and distributed with the header file.. that way, anyone can use it but nobody cann't mess with your code...
6th Jul 2016, 7:19 PM
Nelson Urbina
Nelson Urbina - avatar
0
Yes you can.
6th Jul 2016, 7:00 PM
Garme Kain
Garme Kain - avatar
0
Thanks for all the answers!
7th Jul 2016, 7:15 AM
Christian Roos
Christian Roos - avatar
0
yes you can do that.
7th Jul 2016, 8:25 AM
Mohammed Ahmed
Mohammed Ahmed - avatar