C++ Tutorial 22: Multiple File Projects

preview_player
Показать описание
In this tutorial I want to cover the topic of creating class hierarchies and projects with multiple files.

This topic is not often covered in any detail. C++ courses sometimes tell students to split projects and classes but they're not often specific about exactly how to split them. Folks are sometimes left to figure it out for themselves, and it's not as easy as it seems!

It's like telling someone to ride a bike by saying "you just sit on it and pedal, you'll be right!". It's true, but there's something that bike riders know that non-bike riders don't. Likewise, telling someone "split your classes and project up into headers and CPP files, you'll be right!", is not very helpful...

We need to avoid "duplicate definition" errors and yet split our projects and class hierarchies into separate files, whilst including headers multiple times for any classes that needs them. We do this because it makes a project easier to navigate and maintain, but unless you do it right, it's a massive pain to work with. There's more than one right way to do it, but there's also an awful lot of wrong ways to do it! This tutorial is intended to show at least one, simple, clear and correct way of splitting classes and your project into multiple files.

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

absolutely fantastic in content and presentation! Many thanks!

leythecg
Автор

Love the effort you put in with the slideshow and everything, great video!

YP
Автор

Excellent, Great, No words to appreciate enough. Thank You.

arpitpatel
Автор

What a great tutorial!! :) :) Thanks a lot! I wish I had such detailed classes once when I started learning c++! Cheers!

NevenaPerovic
Автор

Yooo. This video is like super old however I really want to thank you for it.
I was really having problems understanding how headers worked and I had a lot of problems inside my code because of the lack of guards. Seriously thanks!

DownloadableFox
Автор

21:17 how do c++ know that when u wtite Rectangle(sideLen, sideLen) u actually mean the width and height? İ mean, u havent declared anything called "sideLen" in rectangle, so it may be anything, why width and heigth. İ would really appreciate if u helped me with this question, cuz i'm a lil bit confused right now 😅

kerimbendov
Автор

Awesome to know about #pragma once. always wondered why it showed up when I created a new file lol. Also, I added the #ifndef and #define in all my .h files. still having issues. I'm using a function template so the error I'm getting is function template has already been defined. :(

jessicajumelles
Автор

How to Compiler multiple files in vscode?

cigoli
Автор

So extremely useful. Thanks for creating this video.

nicholasfazzolari
Автор

Thank you. Could you please make a similar tutorial for VSCode as well?

zeinabrahmani
Автор

Might want to explain what "#pragma once" is about for us beginners.

... resuming watching.

forresterickson
Автор

hey, why rectangle.h/circle.h are included in main.cpp but not rectangle.cpp/circle.cpp

herootaku
Автор

Thanks for making this awesome video. It could have been better if you would have included namespaces.

shibasispatel
Автор

Very useful, thanks. There is no tutorial in spanish.

DiegoJaraPalomino
Автор

In case may be helpful to those who are new: for VSCode in terminal window (paste and press enter)
cd "f:\prac5\" ; if ($?) { g++ main.cpp Shape.h Circle.cpp Rectangle.cpp Square.cpp -o main} ; if ($?) { .\main }
Note : f:\prac5\ - Replace with your folder address

arpitpatel
welcome to shbcf.ru