C++ - Organize your Functions with Header and Implementation Files (.hpp and .cpp)

preview_player
Показать описание
Learn how to organize your C++ functions with .hpp and .cpp files. Separate the interface from the implementation, using best practices from the start.

0:00 Intro
0:38 Create a header file for the function prototypes
4:12 Create a C++ file for the function definitions
5:38 Use your new library in your main file
7:19 Create a new function with this new code organization
9:11 Outro

Рекомендации по теме
Комментарии
Автор

I have watch 100s of C++ videos and never understood this basic principle but you have just explained it Thank you.

christosioannou
Автор

I searched to find out how hpp files work and now I know. Thanks!

jjclicquennoi
Автор

Finally!! A video that I can follow. Thank

GoddessTee
Автор

If I am including . hpp file then I am getting undefined reference error to function but as soon I include .cpp [implementation cpp file ] code get executed without any error. why so

CaptainCoder
Автор

Don't write std::endl just instead of '\n'.
std::endl call .flush() method for stream and clear its buffer. So you can lose speed of program
Should write std::endl when it's need.
For example, 1:00 in 16-th line, in the end of program, while in 15-th line I prefer '\n'.

P.S. a little bit StackOverflow in comments 🙃😅

КимЧенОрк
Автор

what about namespaces? should I write my cpp functions inside namespaces?

arthurbrc_
Автор

How do we include an hpp in another hpp?

aswinrahardja
Автор

How do you avoid interdependent headers? like headers within headers?

BigJMC
Автор

I did exactly like you demonstrated here but it doesn't work on VS Code. There must be something else you did to make it work.

pinielchitare