Header Files - C++ Tutorial For Beginners #14

  Рет қаралды 153,026

NeuralNine

NeuralNine

Күн бұрын

Пікірлер: 149
@alex_mahone
@alex_mahone 3 жыл бұрын
Love your teaching style! I always learn something new when you post a new video!
@NeuralNine
@NeuralNine 3 жыл бұрын
appreciate it :)
@christreedee
@christreedee 2 жыл бұрын
@@NeuralNine how does one run one of these .h files thanks :)
@scottblake89
@scottblake89 2 жыл бұрын
I love that you jump right into it... it seems like all the most viewed or liked videos start off with trying to sell something and i cant stand that..
@AnonymousUser-ui4vo
@AnonymousUser-ui4vo 10 күн бұрын
then sit dow-
@Guy-bf7wm
@Guy-bf7wm 3 жыл бұрын
Really thank you for these tutorials, I'm starting with competitive programming and I wanted to use c++ and suddenly I saw these videos and they really helped me.
@wangxian7924
@wangxian7924 3 жыл бұрын
This video was very clear and amazingly explained. Learnt a lot! Thank you.
@tamirrozenfeld3572
@tamirrozenfeld3572 2 жыл бұрын
Finally i found a video that explain what header is and not make me watch 30 minutes video hoping to hear or get a hint of what header is ! THANK YOU VERY MUCH!
@krakusek865
@krakusek865 3 жыл бұрын
here I found what I was looking for, a very good video. Thank you bro!
@fatman2217
@fatman2217 3 жыл бұрын
I wasted 3 days looking for a fix on how to include user-made header files, it always caused a linker error in VS Code, can't thank you enough for this video mate :)
@bachirdekdouk5440
@bachirdekdouk5440 7 ай бұрын
How do you configure this include in the tasks.json file if you dont want to do it from command line ?
@m7md_alj
@m7md_alj Жыл бұрын
you have no idea how long i spent trying to figure out how to use the header file tysm
@JoaoPedro-nh7uw
@JoaoPedro-nh7uw 9 ай бұрын
Thank u so much. I was having problem with a function that was being undefined, and you just saved me😃
@rouisaek
@rouisaek Жыл бұрын
The header feels like an Interface. Nice tutorial
@sashokostadinov5773
@sashokostadinov5773 3 жыл бұрын
Thank you so much! I am also using the extension and yesterday we started learning about header files and I was wondering what was I doing wrong. I found from internet which file what should it contain but I could not find why it was not compiling.
@ricardocarvalhomiguel2684
@ricardocarvalhomiguel2684 3 жыл бұрын
Thank you very much for the video, I'm from Brazil and only used C ++ in VS2019, and this video helped me to understand how to compile headers files. I will follow more videos from your Channel
@cenkerozkan9906
@cenkerozkan9906 Жыл бұрын
You explained it very simply and clearly. It couldn't have been explained better. Thanks
@ebiscaia
@ebiscaia 3 жыл бұрын
Hi, is there a way to edit the task.json to include something like "include/*.cpp" to compile everything with F5?
@Aikocake
@Aikocake 2 жыл бұрын
Any update to this inquire?
@ebiscaia
@ebiscaia 2 жыл бұрын
@@Aikocake Unfortunately not
@DerKommandant
@DerKommandant Жыл бұрын
@@ebiscaia Have you found a solution yet?
@ebiscaia
@ebiscaia Жыл бұрын
@@DerKommandant nope, mate. It’s been a while I don’t use C++
@DadicekCz
@DadicekCz Жыл бұрын
​@@ebiscaiabruh, one would say it is one of the most basic things a programmer can do. I'll never stop hating this system
@danieladeba206
@danieladeba206 7 ай бұрын
Wow,Thank you you made me to come out confusion of running c++ with the header files.
@slattsan1315
@slattsan1315 2 жыл бұрын
Great tutorials bro, refreshed my c++ quick and good w this series
@mrbout8911
@mrbout8911 3 жыл бұрын
In the next videos, you can enlarge the font a little to be clear because I am using the phone and thank you for the effort
@DeepakPandey-dn9iz
@DeepakPandey-dn9iz 2 ай бұрын
thank you so much sir. I was facing issues with linking the files.
@janmichaelaustria620
@janmichaelaustria620 3 жыл бұрын
Nice video man! I spent hours trying to find a work around for CMake, and this cleared it up in like 5 mins! You rock!
@33samogo
@33samogo 3 жыл бұрын
how did you compilie with g++ -o main.exe main.cpp includes/calculations.cpp commanad?! is not working for me, it works with g++ main.cpp includes/calculations.cpp -o main.exe. What I am missing here? Is there a way to configure Compile Run "F6" command to work with includes?
@ric7702
@ric7702 3 жыл бұрын
A bad practice but it really works, actually that is the only one that worked for me, I could't made work the one with the header file. I am working with C in VSC. But well at least one way worrked for me. Greetings.
@JianqiuChen
@JianqiuChen 2 жыл бұрын
still does not work, it says main.exe is not recognized! vscode and c++ is the hardest config that I have done in my life, 4 hours watching videos cannot get a damn hello world + another class set up. And are you telling me that I have to run the command "g++ -o main.exe main.cpp includes/mynewclass.cpp" every time I create a new class???
@Matdrox
@Matdrox 2 жыл бұрын
I'm wondering this too...
@sinapiranix
@sinapiranix 2 жыл бұрын
thank you man! youre best teacher for c++
@agentstona
@agentstona 2 жыл бұрын
but what if you have 5 different headers that you use for 5 different things at compile do you have to also specify the other 5 different .cpp files ?
@deadeye8
@deadeye8 2 жыл бұрын
Thats where #pragma once Comes into play
@malolan98
@malolan98 3 жыл бұрын
Keep going! Really great method of teaching!
@sinaghezeljeh2227
@sinaghezeljeh2227 3 жыл бұрын
great video again like every time
@homelikebrick42
@homelikebrick42 3 жыл бұрын
Why should the files have to have the same name?
@Inoom.
@Inoom. 4 ай бұрын
They don't have to.
@robromijnders
@robromijnders Жыл бұрын
This is really great, thanks for posting!
@123userthatsme
@123userthatsme Жыл бұрын
Thank you for explaining the h vs cpp thing, i.e. being able to hide the actual functions in cpp. I didn't understand why the boilerplate was duplicated... it was driving me nuts!
@rouisaek
@rouisaek Жыл бұрын
the .h file is like a contract to the end user. and they are not duplicated cuz the .h file have the declaration methods and the .cpp file must have the definition of that methods.
@AyaGamal2010
@AyaGamal2010 Жыл бұрын
@@rouisaek Good clarification!
@rouisaek
@rouisaek Жыл бұрын
Thanks
@danykmk1174
@danykmk1174 3 жыл бұрын
believe me !!! You are the best for me !!!!! your method is great
@doc9448
@doc9448 3 жыл бұрын
Thanks for your instruction! Very easy to understand and informative!
@livedreamsg
@livedreamsg 3 жыл бұрын
So is there any way to get Visual Studio Code to do this for me? I have to jump to the terminal every time, as Visual Studio doesn't recognize it at all. At that point I'm much better off just using Vim.
@NeuralNine
@NeuralNine 3 жыл бұрын
It's always better to use vim
@tamimkhan7919
@tamimkhan7919 2 жыл бұрын
Thanks teacher this video was really helpful for me.
@danielschaad3084
@danielschaad3084 2 жыл бұрын
what would be the command line in the case I have multiple header files? Do I have to write every single one? or is there a way to compile the whole folder "includes"?
@leonwozniak9456
@leonwozniak9456 10 ай бұрын
i have a same problem, did u find any solution?
@mubarakoyeyinka8520
@mubarakoyeyinka8520 3 жыл бұрын
Thanks a lot :) your explanation did help me!. I am trying to use both g++ and cl compiler and I just follow your example using "cl /Zi /EHsc /nologo /Fe:main.exe main.cpp Random1.cpp" in powershell from the working directory. And that's work!
@clarkniyonzima9724
@clarkniyonzima9724 Жыл бұрын
I have a question, what about the #ifndef, #define and #endif in the header file
@ahmedosama6856
@ahmedosama6856 8 ай бұрын
Its a best practice for files validation
@ayushdubey8745
@ayushdubey8745 2 жыл бұрын
How to run a project with a single header file and multiple source files?
@enigma3292
@enigma3292 3 жыл бұрын
Great vid!
@NeuralNine
@NeuralNine 3 жыл бұрын
thanks :)
@hallucinatory.767
@hallucinatory.767 2 жыл бұрын
Thanks for the tutorial bruh! That's Amazing.
@hyperbhavik
@hyperbhavik 2 жыл бұрын
Finally got it, thank you very much
@catorlife
@catorlife Жыл бұрын
for some computers, you can't run the "main.exe" command in the terminal, you need to rewrite it as ".\main"
@Allusioo
@Allusioo 10 ай бұрын
thanks bro
@rodrigotorres6426
@rodrigotorres6426 3 жыл бұрын
Nice video, months to searching this!!
2 жыл бұрын
So, linker identify the implementation of the declaration just by the same filename? What about include guard i learned in C. its not relevant anymore?
@evrolcuk2046
@evrolcuk2046 2 ай бұрын
does "not adding the .cpp file" directly have any importance in terms of privacy? i didn't get that?
@yumyumtales
@yumyumtales 2 жыл бұрын
Great video !!! very well explained
@dakshdesai
@dakshdesai 3 жыл бұрын
Sir can you make a obs studio with python
@inx1819
@inx1819 3 жыл бұрын
lmfao
@juanjocg1870
@juanjocg1870 3 жыл бұрын
xddd
@xfire3778
@xfire3778 3 жыл бұрын
What does this even mean?
@larissasouza8169
@larissasouza8169 3 жыл бұрын
Great video, thank you so much for that!
@ali_youtube_user_7351
@ali_youtube_user_7351 4 ай бұрын
How can I make a header file with its imolementation file that can be included and used across any cpp filed without explicitly including it to your project ? Just like C++ header files (iostream, vector, etc)
@ZAblaze
@ZAblaze 6 күн бұрын
thank you in 2nd class of programming and they taught this in the first one but i didn't pay attention in that lesson lmao
@syldris
@syldris 3 жыл бұрын
Is there any way to run (or execute) the main code(main.cpp) without typing a command such as "g++ -o main.exe main.cpp calculations.cpp"? In Visual Studio (not VS Code), it allows to users to have a class with its header file(.h) and definition file(.cpp) and run it without any single special terminal command, as long as all the files are in the project folder. It seems like VS Code does cannot find the header file's directory on its own.
@luke7049
@luke7049 3 жыл бұрын
The 'button' you press in Visual Studio is basically an automated implementation of compiling the source code (i.e using the terminal command)
@hodayfa000h
@hodayfa000h Жыл бұрын
BRO just use visual studio it is 100 times better
@hodayfa000h
@hodayfa000h Жыл бұрын
of course as an ide Not a code editior
@syldris
@syldris Жыл бұрын
@@hodayfa000h Agreed! Already swapped to VS!
@hodayfa000h
@hodayfa000h Жыл бұрын
@@syldris oh yeah this was 1 year ago of course it changed
@Galaktium
@Galaktium 3 жыл бұрын
Nice vid, very clear, very helpful.
@lucasjoss5733
@lucasjoss5733 3 жыл бұрын
tanks bro, you realy help me to solve the compiler error
@ViktorKatzy
@ViktorKatzy 8 ай бұрын
The only reason why his C++ code works is that it's afraid of his biceps an getting punched 😹😼 but jokes aside, very good explanation, really helped me out!
@AbhishekYadav-ni5ts
@AbhishekYadav-ni5ts 2 жыл бұрын
Thank u very much...... This video helped me alot... Thank u 🙏🙏
@TheUruz
@TheUruz Жыл бұрын
what if you end up having to compile two files with two implementations of, say, the add function?
@gvega6227
@gvega6227 3 күн бұрын
Are there any alternatives to this? I have tried several times and enterin g++ -o main.exe main.cpp includes/calculations.cpp into the terminal doesn't seem to do anything.
@gvega6227
@gvega6227 3 күн бұрын
specifically, the error is: C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Gabe\AppData\Local\Temp\ccVkqsFx.o:main.cpp:(.text+0x18): undefined reference to `add(int, int)' collect2.exe: error: ld returned 1 exit status
@AyaGamal2010
@AyaGamal2010 Жыл бұрын
for this problem in VS code : The term 'g++' is not recognized as the name of a cmdlet, function,.... solution : kzbin.info/www/bejne/a5m2g5SNadiqqtEsi=zzxcLPnKLhjL0cP3
@aashishpanchal3022
@aashishpanchal3022 3 жыл бұрын
Thankyou so much sir, really help full.
@DrFerdy
@DrFerdy 2 жыл бұрын
dude,you are using the different version of microsoft visual studio that i use,probably that "most" people use we use the community version
@jersondereal
@jersondereal Жыл бұрын
Help🥲 The command isnt working, i keep getting this error, cc1plus.exe: fatal error: main.cpp: No such file or directory compilation terminated.
@AyaGamal2010
@AyaGamal2010 Жыл бұрын
for this problem in VS code : The term 'g++' is not recognized as the name of a cmdlet, function,.... solution : kzbin.info/www/bejne/a5m2g5SNadiqqtEsi=zzxcLPnKLhjL0cP3
@vukkulvar9769
@vukkulvar9769 Жыл бұрын
Why can't gcc implicitely fetch all the needed files? Why can't you declare what's made visible outside the .cpp file without using a .h file, but by using a "export" keyword for example?
@AyaGamal2010
@AyaGamal2010 Жыл бұрын
for this problem in VS code : The term 'g++' is not recognized as the name of a cmdlet, function,.... solution : kzbin.info/www/bejne/a5m2g5SNadiqqtEsi=zzxcLPnKLhjL0cP3
@juanjocg1870
@juanjocg1870 3 жыл бұрын
love it
@junkdog505
@junkdog505 3 жыл бұрын
Gracias a tu video encontré la forma de ejecutar los headers no lo encuentro en otros videos se me hace muy pesado el visual studio 2019 ty
@skaterfabi11
@skaterfabi11 3 жыл бұрын
Thx 4 your videos :)
@Steezylegs_juri
@Steezylegs_juri Жыл бұрын
really well done thanks
@killzann7757
@killzann7757 3 жыл бұрын
love it bro
@antmoundsock1122
@antmoundsock1122 2 жыл бұрын
i get 3 errors depending on my variables: 'x': identifier not found, 'y' undeclared identifier, and 'z': redefinition, multiple initialization
@BunrithViwatthanak
@BunrithViwatthanak 19 күн бұрын
What is the keyboard?
@Rita-og7cy
@Rita-og7cy 3 жыл бұрын
wait you might have just saved my life
@Rita-og7cy
@Rita-og7cy 3 жыл бұрын
nope still not working
@lal1th
@lal1th 3 жыл бұрын
Okay, so I don't usually comment on videos but this annoyed the hell out of me so I am going to comment if someone else has the same issue If everything works up till the point where he types main.exe and then it just shows you an error message, make sure you are using command prompt as your terminal, or use the equivalent command in your terminal Great video tho! 👍 (edit: just some punctuation)
@naheliegend5222
@naheliegend5222 2 жыл бұрын
But what if I have 100 of those header files and cpp files? Should I add all of them to the g++ command?
@guigs4467
@guigs4467 Жыл бұрын
#pragma once
@Robin-gd8py
@Robin-gd8py Жыл бұрын
Thank you so much.
@Jonathan-ru9zl
@Jonathan-ru9zl 2 жыл бұрын
Hi! How come i have .cpp file that uses stdio.h library and uses printf function?
@saadblabla
@saadblabla 8 ай бұрын
I still don't get why you would use header files if you can use the cpp instead, you are not hiding your source code using h files the implementation in cpp files shows all the files there.
@randomhuman5539
@randomhuman5539 3 күн бұрын
You saved me thank you
@byrussx
@byrussx 3 жыл бұрын
great video
@NeuralNine
@NeuralNine 3 жыл бұрын
thanks :)
@DepechLyot
@DepechLyot 3 жыл бұрын
Greetings from russia! and thank you for teaching me!
@casperongny802
@casperongny802 3 жыл бұрын
Hey, what is your intro? BGM
@RenderDragon
@RenderDragon 3 жыл бұрын
You should name your channel as Brainpods
@alexsonic7
@alexsonic7 Жыл бұрын
bro everybody is asking about several includes, i think that can be achieved with a makefile
@mrentp
@mrentp 9 ай бұрын
Isn't this working as interfaces ??
@tips1483
@tips1483 3 жыл бұрын
Can you livestream you coding some day :)
@NeuralNine
@NeuralNine 3 жыл бұрын
it's on my todo list. sooner or later I will do it :)
@tips1483
@tips1483 3 жыл бұрын
@@NeuralNine Ok thanks!
@HousseinAlDroubi
@HousseinAlDroubi 2 ай бұрын
Good, welcome to you.
@Sakapaka
@Sakapaka Жыл бұрын
i didnt understand how the calculations.h had access to the calculations.cpp because u didnt inclue the cpp file in the header file
@rouisaek
@rouisaek Жыл бұрын
It happens under the hood cuz of the naming conventions. all you need to know is your xxxx.cpp file that have the implementation of the logic must have a xxxx.h file with the exact name that acts like an interface for the users. Now inject the xxxx.h not the xxxx.cpp that must be private.
@costantinoanea682
@costantinoanea682 3 жыл бұрын
🤩
@catorlife
@catorlife Жыл бұрын
gosh, why it's so difficult, too many perplexed frameworks you guys just need to switch to VS (purple one) and then you will see it much much easier, just "pragma once" and then everything is on the set
@Hoxolotl
@Hoxolotl Жыл бұрын
so instead of including calculation.cpp you include calculation.h. And the only use for a header file is to make the code more readable by moving the logic back to a second file. Why does it feel like using a sledgehammer on a mosquito? As if back in the days when C was invented "readability" was on the menu. I bet there is a better reason why header files exist. I'll go look it up.
@shahidashadan4104
@shahidashadan4104 3 жыл бұрын
I'm currently using arduino IDE software,but when I'm trying to upload the coding,there are some error and it show a message 'no header files (.h) ' What should i do? Anyone help me please? I really need your help.
@shahidashadan4104
@shahidashadan4104 3 жыл бұрын
And if i not notice someone reply my comment,kindly dm me at instagram. Tq in advance Ig : nrlsy_hda
@joaquins.a.2830
@joaquins.a.2830 3 жыл бұрын
In my case it only worked with include "calculations.cpp" or include "calculations.h". with include "includes/calculations.cpp or .h" i got an error.
@ASHISHKUMAR-gh1uu
@ASHISHKUMAR-gh1uu 3 жыл бұрын
After creation of main.exe Include your header file in calculation.cpp file i.e #include"calculation.h" And then in main.cpp makes changes of #include "Includes/calculation.h" After that in new terminal Write g++ -o main.exe main.cpp Includes/calculation.cpp Hit enter And then write main.exe It will give result
@dankcherries22
@dankcherries22 3 жыл бұрын
@@ASHISHKUMAR-gh1uu He has his calculations.h file in a folder called includes, so "includes/calculations.h" is the path to the calculations.h file. If your calculations.h file is in the same folder as your main.cpp file you only need to have #include "calculations.h"
@thechosenone7465
@thechosenone7465 Жыл бұрын
thanks you❤
@uhhuh5934
@uhhuh5934 11 ай бұрын
Thanks
@beauMax
@beauMax Жыл бұрын
Classes?
@Rhapsolin
@Rhapsolin 7 ай бұрын
for me it wasn't #include "includes/calculations.cpp" it was just #include "calculations.cpp"
@chabaned4743
@chabaned4743 4 ай бұрын
thanks
@petermuller161
@petermuller161 3 жыл бұрын
I read that these function signatures have been called function prototypes. Forgive me I am learning.
@tecfy028
@tecfy028 2 жыл бұрын
I think this are 2 different names for the same thing
@mengjingyang4596
@mengjingyang4596 3 жыл бұрын
why the last step is to type main.exe
@badmonkey2468
@badmonkey2468 Жыл бұрын
very good
@gabriellebtrc
@gabriellebtrc 3 жыл бұрын
5:58 2:43
@Devansh__Pandey2409
@Devansh__Pandey2409 3 жыл бұрын
includes is not working for me
@tips1483
@tips1483 3 жыл бұрын
3rd
Global Variables - C++ Tutorial For Beginners #15
9:01
NeuralNine
Рет қаралды 12 М.
What are header files in C++ ( PROGRAMMING TUTORIAL for beginners)
23:54
НИКИТА ПОДСТАВИЛ ДЖОНИ 😡
01:00
HOOOTDOGS
Рет қаралды 2,8 МЛН
小丑家的感情危机!#小丑#天使#家庭
00:15
家庭搞笑日记
Рет қаралды 35 МЛН
Don't look down on anyone#devil  #lilith  #funny  #shorts
00:12
Devil Lilith
Рет қаралды 48 МЛН
Flipping Robot vs Heavier And Heavier Objects
00:34
Mark Rober
Рет қаралды 59 МЛН
Cronos Developer Workshop: SubQuery
38:17
Cronos Chain
Рет қаралды 36
C++ Header Files
15:10
The Cherno
Рет қаралды 729 М.
why do header files even exist?
10:53
Low Level
Рет қаралды 420 М.
Makefiles Make Your Life Easier
12:05
NeuralNine
Рет қаралды 105 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 806 М.
Vim Tips I Wish I Knew Earlier
23:00
Sebastian Daschner
Рет қаралды 72 М.
how Google writes gorgeous C++
7:40
Low Level
Рет қаралды 917 М.
Short introduction to header files in C
13:34
CodeVault
Рет қаралды 86 М.
НИКИТА ПОДСТАВИЛ ДЖОНИ 😡
01:00
HOOOTDOGS
Рет қаралды 2,8 МЛН