C++ Splitting your Code into Multiple Files

preview_player
Показать описание
For larger projects, you will want to split your code into header files (.h) and source code files. This will allow you to re-use your classes in multiple projects. It will cut down on compile time because potentially only some of the files need to be re-compiled.
Рекомендации по теме
Комментарии
Автор

Thank you so much! I have seen so many videos trying to make class header files but to no avail! You solved my problem in the first 1.20 minute! Thank you again!

rafbi
Автор

A few years later and still an awesome video. Thank you kindly

naeemahmanto
Автор

You're not my professor, but I appreciate your work!

adokat
Автор

Needed a better understanding on this topic. Thanks! You earned another sub. Please keep teaching!

Toothless_Rides
Автор

which software are you using & thank you for this informative and to the point video

nipunmittal
Автор

Thank you so much !! Header files so important!!

jrm_music
Автор

Thank. This part for confusing me for hours.

protennis
Автор

*this* inside the constructor is not needed even if the prototype's arguments names are the same as the private data.

tomfranky
Автор

thank you so much to make this video you are a very good teacher very good

mkwriterchannel
Автор

Just curious, what IDE is it that you use?

dooglive
Автор

Hi! I am from India. I have just learnt C++.
I define those function in the class only. Means all logic in inside the function in the class.
So, my question is - what the difference if we define the function in the class or outside the class(As shown in video). As i know that the memory allocated to variable leaves going outside the { }.
If there are more function defined(implemented) inside the class, will instance of that class(while created) takes more memory.
Or nothing will effect wethere defined inside or outside(as shown in the video) the class.
Thanks👍

anandajay
Автор

hey, can you make a video on how to split generic ( template ) classes in different files?

mayankk
Автор

Thanks for explaining this. I didn't really got the idea of c++ code splitting until know.

klikrzys
Автор

Exactly what I've been looking for not more not less, thanks

ilyassilyass
Автор

I think Date(int month = 1, int day = 1, int year = 2019) func is not a default function. Default function should be like this: "Date()". what do you think of that?

senemyildiz.
Автор

its not working for me. I am not getting an error but it's just not workign for me. Its not printing anything. it says"undefined reference to `Date::Date(int, int, int)' "

devangpatel
Автор

not sure why that is, but for me it worked fine just splitting the header, but when i made a seperate source file, i had to #include "date.cpp" for my project to work

kairi
Автор

Im struggling with this because for some reason, the linker keeps throwing an "error: ld returned 1 exit status" and when i look in the build log, it throws a lot of "first defined here" messages. I have my guard on and made sure that my #include was in both my main.cpp and my class.cpp ..

astralnomad
Автор

Fantastic video, just discovered your channel! You have a new subscriber! :)

NewLondonMarshall
Автор

I don't really understand why you should use a second cpp file when you can just put everything into one header file and than include the headerfile and than just use it in the main file. Can you tell me pls?

voluptua