How to Write a C++ Class

  Рет қаралды 423,829

The Cherno

The Cherno

Күн бұрын

Пікірлер: 284
@PigeonTendies
@PigeonTendies 7 жыл бұрын
You're probably the only person out there with this level of production value helping people how to code, keep it up man, you're a real help
@yaelmilo70
@yaelmilo70 3 жыл бұрын
I know Im asking randomly but does anyone know a method to get back into an instagram account?? I was dumb forgot my password. I would love any help you can offer me.
@anonymouscyborg5610
@anonymouscyborg5610 3 жыл бұрын
@@yaelmilo70 Forgot Password Function: I am not even here baby, I am hallucination
@GamePilLP
@GamePilLP 2 жыл бұрын
@@anonymouscyborg5610 And I started to realize: I am not hallucinating, I am the hallucination. I have become hallucination. The Destroyer of sanity
@kibeyt
@kibeyt Жыл бұрын
@@yaelmilo70 if you send me $100 i wont get your instagram account back but I will use the $100 to buy myself a new mouse :)
@krakor92
@krakor92 6 жыл бұрын
0:42 Damn you dynamically cropped the amazon logo with your arm for only 5s of video. I'm impressed!
@TheDuckPox
@TheDuckPox 6 жыл бұрын
you do know he can do that automatically right?
@krakor92
@krakor92 6 жыл бұрын
Nop i’m a low-skilled video editor ^^’
@kylevn01
@kylevn01 6 жыл бұрын
@@krakor92 he may be used adobe after effect for the 3D text.
@thewiedzmin6062
@thewiedzmin6062 6 жыл бұрын
This is one the nerdiest comments I have ever seen in a nerdy video!(I mean in a good way of course!)
@marflage
@marflage 5 жыл бұрын
Had you not pointed it out, I might not have known
@StarContract
@StarContract 7 жыл бұрын
I'm glad you got sponsored. Heads up for the company that financially reward people like you who spread knowledge
@austinsilva7025
@austinsilva7025 20 күн бұрын
Currently binge watching this series lol. Even though he made this 7 years ago its still the best c++ tutorial series i've seen so far.
@PhoenixWrong0
@PhoenixWrong0 19 күн бұрын
ikr
@ItsRyanStudios
@ItsRyanStudios 5 күн бұрын
I'm here in 2025 as well!
@asmrkratosbone4337
@asmrkratosbone4337 Жыл бұрын
Thanks!
@Rahib-gv6gd
@Rahib-gv6gd 2 күн бұрын
20$ and no replay ??
@carrapaz3645
@carrapaz3645 4 жыл бұрын
9:50 cherno: "this class is trash" me who worked 1 and a half hour copying and expanding on this class: T_T
@DonaldMurf
@DonaldMurf 3 жыл бұрын
same
@forhadrh
@forhadrh 3 жыл бұрын
LOL! 😆
@yeadatwunyt8004
@yeadatwunyt8004 3 жыл бұрын
resonating with the collective "bruh" of 260+ people around the world
@phu2110
@phu2110 11 ай бұрын
fr
@mastershooter64
@mastershooter64 3 жыл бұрын
3:14 "Alright there we go done, _can I go now?_ " literally almost every student in every school ever
@igniex
@igniex 3 жыл бұрын
I started watching this C++ series and I just wanna say, you're awesome at presenting and communicating this information! I have some surface-level knowledge of these concepts already, but I can tell I'm learning quite a lot from these videos already. Thank you for sharing the knowledge you've gained with experience, and so concisely.
@hispantrapmusic301
@hispantrapmusic301 2 жыл бұрын
How u doing now?
@goombone1717
@goombone1717 Жыл бұрын
​ how its going ur learning?? you became a great dev in this 2 years or quitted?
@thomasmcoscar681
@thomasmcoscar681 5 жыл бұрын
I love how you go through what is functionally necessary vs what is convention and standard practice. This does so much to help us understand what is happening and why. I'm super looking forward to continuing through this C++ course and then eventually into OpenGL.
@srisairayapudi6074
@srisairayapudi6074 2 жыл бұрын
Hey, I was curious to know if you did get into the OpenGL course. I'm doing this C++ right now and wanted to know if i should do OpenGL next or not. I'm interested in both game dev and game design, but I don't know what to start next, but I love Cherno's way of explanation and wanted to know which to do next. Hope you read this and Thanks in Advance!
@goombone1717
@goombone1717 Жыл бұрын
​ @srisairayapudi6074 how its going ur learning?? you became a great dev in this 6 months or quitted?
@sablanex
@sablanex 7 жыл бұрын
Nice to see some sponsors!
@sablanex
@sablanex 7 жыл бұрын
Log class done, can I go now. LMAO
@abdulmoizsheikh8031
@abdulmoizsheikh8031 7 жыл бұрын
I spat my coffee lol
@ToxicityGameDev
@ToxicityGameDev 6 жыл бұрын
Yes, was def funny haha
@sha1_________________54
@sha1_________________54 5 жыл бұрын
I don't get it.
@martingaens2073
@martingaens2073 5 жыл бұрын
@@sha1_________________54 3:10
@sha1_________________54
@sha1_________________54 5 жыл бұрын
@@martingaens2073 that was 8 months ago but thanks for explaining the joke
@NurGarciaTerrassa
@NurGarciaTerrassa Жыл бұрын
My university teacher recomended theese lessons in order to prepare me for their own internship, and just a few videos in I'm already learning a lot! Thank you for theese high quality lessons!
@HappyMatt12345
@HappyMatt12345 2 жыл бұрын
I went ahead and named the log level variables LevelWarning, LevelMessage, and LevelError instead of LogLevelX because when you write them out outside of the class, you get Log.LogLevelX which is a bit redundant and Log.LevelX reads a lot better. Nitpicks out of the way, very informative tutorial as always!
@michaelblackmer8183
@michaelblackmer8183 3 жыл бұрын
This is the best C++ series I've seen on youtube. I know how to program, just trying to get a handle on the language and the syntax. Thanks man.
@roja
@roja 3 жыл бұрын
Commenting for your exposure. The best channel on KZbin for C++ !!!
@gethriel
@gethriel Жыл бұрын
Loving the videos! Thank you. With programming I'm the opposite: if I really want to focus, I go to silence. Now, if I want my workday to fly by, music; but that cuts productivity for me (not necessarily a LOT), and these days i would rather be productive.
@leixun
@leixun 4 жыл бұрын
*My takeaways:* 1. Convention for writing class member variables 4:48 2. Using more than one public to separate variables and methods 6:10
@rongarza9488
@rongarza9488 Жыл бұрын
The best part of the video is after 10 minutes when you say this is not the way it is done. Great, thank you very much. 12,000 people probably thank you too.
@runetimon
@runetimon 7 жыл бұрын
Nice! very interested to see how you improve this.
@ronboprime
@ronboprime 4 жыл бұрын
Omfg dude. what the hell is this? I have been reading articles and books and whatnot trying to teach myself code since this whole covid thing went down. I been struggling with classes the last little while. You, though! YOU! thank you! so very much! Also, your conventions are really handy, and help out tons! I like the structure and speed of your videos as well. All Killer, no filler. Thanks again! Keep on keepin on!
@karthicksaran65
@karthicksaran65 4 жыл бұрын
3:13 Me in classroom literally every second
@radekseky4571
@radekseky4571 3 жыл бұрын
You really should have done this traditionally from top to bottom. The fact that you wrote in main first, coupled with your fast writing and explaining, resulted in me being pretty much stunned looking at the screen the whole time, failing to follow, and then the video was over. At the end with all the code copied in front of me it helped a lot as a guidance through all the additional replays.
@smileynetsmileynet7922
@smileynetsmileynet7922 3 жыл бұрын
Rewatching this because I need to remind myself about classes in C++. I'm going to add them to my language pnf. Right now, it should be able to do what C can.
@DTGplays
@DTGplays Жыл бұрын
Love the series. I wish I did not have to work a crappy 9-5 and could dedicate my whole time to learning C++. Keep the great content up!
@modernmage
@modernmage Жыл бұрын
same
@21pandas71
@21pandas71 Жыл бұрын
This series is addicting, thanks
@sebve9399
@sebve9399 5 жыл бұрын
Please make a series about C, I'll watch everyone of the videos 100x I promise.
@mariacunha8508
@mariacunha8508 2 жыл бұрын
So grateful for your channel, honestly!! Saving me a day before midterm
@marflage
@marflage 5 жыл бұрын
Thank God you explained at the end of the video how you would never use this type of messy code, otherwise I was gonna be over-smart here and write the code neatly. Through the whole video until the the point where you clarify, I was thinking "Noway, he writes this type code. His other videos are the opposite". Nevermind, I am just dumb
@voodoomotion5855
@voodoomotion5855 5 жыл бұрын
I've watched a few of your tutorials now and wanted to say big thank you for the effort you've put in. Always nice listening to someone who is enthusiastic about what they do and communicates it so clearly. I haven't programmed in C++ since the mid 90s and even then my skills were a bit hit and miss. It's been a steep-ish learning curve getting to where I need to be to programme plug-ins for After Effects, and you are definitely helping me all the way! Thanks and merry Christmas!
@arielvinda6624
@arielvinda6624 7 жыл бұрын
rad new hairstyle Yan!
@youssofprogrammer7546
@youssofprogrammer7546 2 жыл бұрын
I love these videos that you make very thanks for you the cherno and especially I love that chicken in the background
@christoforostsiolakis415
@christoforostsiolakis415 2 жыл бұрын
Second time watching these. What an amazing series thank you!
@marchenwald4666
@marchenwald4666 3 жыл бұрын
0:42 *How qualitative do ya want your video to be?* The Cherno : *Yes*
@AlexTheGreatish
@AlexTheGreatish 6 жыл бұрын
3:12 How I feel after writing one line of code at work.
@anshulb.9212
@anshulb.9212 4 жыл бұрын
how it feels to chew 5gum
@nincompoop17
@nincompoop17 3 жыл бұрын
You are an absolute legend
@rae4652
@rae4652 5 жыл бұрын
6:30 Why not use enums? :O
@rafal9ck817
@rafal9ck817 3 жыл бұрын
i did put Enum in there just to delete it few seconds later... 9:58 here is answer.
@w3w3w3
@w3w3w3 5 жыл бұрын
Great video! I deffo had a moment like... I would never do this like this lol. But I get why you have done it, and I tried to take away the main syntax and c++ points from it. Thanks!
@richtourist
@richtourist 7 жыл бұрын
Great! Looking forward to seeing how you adapt this to be 'production' code. Like your style, clarity, and just the right speed, not too slow, nice and succinct. Damn, looks like I am going to have to head over to Patreon and do the right thing :-)
@janusztarczykowski9003
@janusztarczykowski9003 6 жыл бұрын
I really like your videos, and the way you explain things, but as someone with a bit of experience in software development I'd recommend two things: not creating big classes with multiple functionalities (also called Singe Reponsibility Principle in SOLID princples) and not using hungarian notation in modern code, it makes code less readable and can introduce bugs. A really good book by Stephan Roth called "Clean C++" is a great resource to learn to write modern cpp code.
@Robinglover3175
@Robinglover3175 7 жыл бұрын
Great idea for a few episodes!
@edpearce2281
@edpearce2281 5 жыл бұрын
Could you use an enumeration type for the log level warning?
@maxterdonado2013
@maxterdonado2013 4 жыл бұрын
Thank you for your effort in teaching, I love the way you keep it simple and entertaining yet you don't treat your audience like preschoolers, that kind of condescending language used by some youtubers can get annoying. Subscribed :)
@ZubairKhan-yg4xy
@ZubairKhan-yg4xy 6 ай бұрын
Thanks for this amazing series... I love you 😭😭😭
@ItachiUchiha-wd5kk
@ItachiUchiha-wd5kk Жыл бұрын
You have the best videos in c++ Thank you so much for such cool content Unfortunately, this video stopped displaying any automatic subtitles after 2 minutes, which made it difficult to translate the meaning of the text But still, thank you for having such high-quality content thanks to you
@SeamanGR
@SeamanGR 6 жыл бұрын
Your channel is a treasure! Thanks!
@gokulram4950
@gokulram4950 2 жыл бұрын
Can you also talk about Design patterns and some examples to implement it in C++
@bottlecapbeaver
@bottlecapbeaver Жыл бұрын
9:55 You really should have said that in the beginning 🤣. I was freaking out that there was something that I was missing, but it really was just a simple, categorizes I guess? message executor.
@JayKalunge
@JayKalunge 11 ай бұрын
It got a little complicated in a short time but your explanation skill handled the complexity very well... tough I won't recommend this series to absolute beginners who just thought of learning C++, you might have to know a little about these concepts before following this this series... but its no harm to follow even if you are a beginners, its just that you might have to search a lot of things to get the idea what's really going on here overall i would say its a great series... its good that we get all the useful information in just short amount of time 😊
@CubedAgency
@CubedAgency 3 жыл бұрын
Awesome content! I've been following this tut series from the beginning. Your production value is fantastic and I do like that you cut back and forth between the screencap and yourself talking. However, as a person learning and following along with you and your code, I do prefer to see the screen longer instead of cutting back to yourself. When following coding tuts I let the speaker continue talking as I keep referencing the code while typing to keep up. Unfortunately, the cutaways are so quick that I keep having to stop your video to see the actual code you just wrote. Again, I love the content and I think your teaching ability is great and super easy to follow along with! But sometimes when you cut back to the screen, the part I'm looking for is now offscreen and I have to skip backward a few times to see what code I missed. Hope this helps inspire future videos. Keep up the great work! I subscribed, and I've been liking all the videos along the way! Hope it helps you!
@popcultureprogrammer2171
@popcultureprogrammer2171 2 жыл бұрын
A little thought I had about a better way to implement this - make m_LogLevel an int that stores flags corresponding to different levels. For example, the warning's if clause could be if(m_LogLevel && logLevelWarning){...}. The user could define more than just three types of messages to print. Maybe define a struct called logMessageType that holds a const char* and a bit mask (set to 2^N), which the log class could use to display that message type (using the const char * when printing the message type, eg "[GRAPHICS]: OpenGL is deprecated" using a list of those structs Maybe that struct can also hold which color to use when printing?
@yiqiou1767
@yiqiou1767 Жыл бұрын
"A lot of you watching this video being like 'what code even this is'". I am absolutely not one of them and feel this is exactly how i will write log class.....
@ricgreen1
@ricgreen1 2 жыл бұрын
Huge Thank you Cherno!
@atilacorreia
@atilacorreia 5 жыл бұрын
I would use Bit Fields for the type of log messages. No need to carry a whole integer for that, but I'm sure you know that. I haven't seen Bitwise operations in any of your other videos. Maybe it's a good topic for a new one. Cheers!
@kadeska2386
@kadeska2386 3 жыл бұрын
Good video man. Thank you for the videos, they are helping me learn.
@jarisipilainen3875
@jarisipilainen3875 6 жыл бұрын
6:42 i was like thinking now he #define LOG_LEVEL_ERROR 0. question would that work same?
@MsJavaWolf
@MsJavaWolf 5 жыл бұрын
Sure. I would not overuse macros though, with variables you will get compiler checks for the correct types etc, it's usually safer.
@wildstomper6232
@wildstomper6232 6 жыл бұрын
Hello! I know this is video was uploaded 1 year ago but I need to ask this question. What's the difference between header and class? I am aware that you'd need to include header file such as #include, but isn;t this same? Aren't headers used to make things more prettier(aligned)?
@zalchan2937
@zalchan2937 6 жыл бұрын
I'm not sure if you still need the answer but traditionally, when you're working on a big project, you might use header files to define classes. You're pretty much right that its main purpose is organization. Also, in c++ you include your header files as #include"class.h" instead of using But basically a header file is just a separate file that interacts with a .cpp file and it mainly consists of class definitions. Yikes I hope I even understood the question @.@
@bondymagnomous3544
@bondymagnomous3544 7 жыл бұрын
So, the next episode will be enum, right?
@BOTHLine
@BOTHLine 7 жыл бұрын
Or static methods/attributes. Since he always has to create an instance of Log. If he wants to use the Log functionality in basically every other class, he has to handle the same instantiation in all of these classes (unless he wants to use different instances.. but I don't think that'd be the point). It could even go as far as to show the concept of singletons.
@MrAlbinopapa
@MrAlbinopapa 7 жыл бұрын
Unless he needs the Log object to persist, creating new instantiations at the log site wouldn't be that bad, no reason to keep a pointer/reference around. In the example, there is few members and instantiating a class like this wouldn't be too expensive and there wouldn't be a need to have the object to persist. If you are writing out to the console then all messages will be appended, if logging to a file, you can open in append mode, and the message will be added to the end for you. This way, you won't keep a file open longer than you need. Plus, having different instantiations would allow you to log different aspects to different files with the same interface.
@bondymagnomous3544
@bondymagnomous3544 7 жыл бұрын
Josh Smith Great note. As always, it all depends on what exactly are you trying to achieve.
@BOTHLine
@BOTHLine 7 жыл бұрын
Sure, if you talk about a project of that size. But I think he will always plan for the future. And then you have to consider about something like that. You'll have your huge engine and then you don't want to instantiate a new instance of log all the time. And logging into different files with the same instance isn't a real problem too. You can organize the different log types within enums and thus use them to chose from different files to write in.
@genotessitore1042
@genotessitore1042 4 жыл бұрын
Can anyone explain why, at 4:40, he needs to make the m_LogLevel private? Why couldn't it just be a public variable called LogLevel and the SetLevel function adjust the LogLevel for that particular instance of Log in our main program?
@shaikhshehzad024
@shaikhshehzad024 4 ай бұрын
It is a good practice, maybe?
@shaikhshehzad024
@shaikhshehzad024 4 ай бұрын
I have seen so many codes that make the functions like set_variable(value) to initialize the value of a private variable rather than making the variable public and writing something like object.value=x. They don't explain why they do that.
@shaikhshehzad024
@shaikhshehzad024 4 ай бұрын
Nvm I asked chatgpt and it said that one of the reasons to do it is not allowing any external code to alter our variables.
@tunamusic2314
@tunamusic2314 4 жыл бұрын
does anyone know why he uses the pointer at line void Warn ( const char* message ) is it necessary to use it, as I known pointer to store the address and value of a variable so what its role in there? can anyone explain? thanks so much
@joseluismatabuenasedano6881
@joseluismatabuenasedano6881 Жыл бұрын
Amazing series, I am learning a lot with your videos. Just a quick question, I don't know if it might be in another video, what is the difference between . and :: when calling variables/functions from another class?
@zoriiginalx7544
@zoriiginalx7544 Жыл бұрын
Member selection vs namespace resolution
@HuyNguyen-fp7oz
@HuyNguyen-fp7oz 4 жыл бұрын
super! love your channel alot. Finally, i can understand many C++ concepts which made me very confused during university years
@Undead34
@Undead34 Жыл бұрын
I liked that hair, it looks like the Final Fantasy hair, it looks fantastic.
@nazar1744
@nazar1744 7 жыл бұрын
oh man....this is the first video I didn't understand.
@anilrao9819
@anilrao9819 4 жыл бұрын
you are wonderful brother keep going!!!!!
@sconosciutosconosciuto2196
@sconosciutosconosciuto2196 5 жыл бұрын
6:45 enums?
@KennyTutorials
@KennyTutorials 4 жыл бұрын
Because this video about classes not enums.
@brunooliveirasoares7489
@brunooliveirasoares7489 5 жыл бұрын
makes no sense the number of views vs number of Likes Tks for the wonderful job!
@gmfCoding
@gmfCoding 7 жыл бұрын
Nice video. I am really looking forward to the next one.
@antoinebguitar2869
@antoinebguitar2869 9 ай бұрын
Good thing he clarified at the end, i was worried for a sec haha like if i gave that type of code to my teacher, i have negative mark lol
@maddoo23
@maddoo23 2 жыл бұрын
Love this series, probably the best on youtube for C++. However, this class was the single most boring class ever coded on video!
@xkilla911
@xkilla911 2 ай бұрын
tutorial starts at 3:11
@bascik
@bascik 5 жыл бұрын
the chuck looks class
@playonce4186
@playonce4186 4 жыл бұрын
Where is the improved version or how would it be improved?
@briggsmedia4045
@briggsmedia4045 6 жыл бұрын
Did you rotoscope a mask of your arm over "amazon music" at 0:40 !? Im big into motion VFX
@sammcelhannon2807
@sammcelhannon2807 5 жыл бұрын
Surely it's possible to have the amazon music logo only show up on static parts of the image, so he probably didn't manually rotoscope it.
@colinmaharaj
@colinmaharaj 2 жыл бұрын
I know this has been a while. I have 1 parameter that says the name of the log file. also I added critical sections because I have lots of calls that needs logging in many threads.
@parko1965
@parko1965 4 жыл бұрын
Why no header file to accompany your class? I thought classes consisted of Declarations and Definitions hence header and cpp files.
@zephyr7
@zephyr7 4 жыл бұрын
That is only done when you want to have your classes in different files, but in this case he declared and defined his class in the same file he will be using it in
@parko1965
@parko1965 4 жыл бұрын
@@zephyr7 Gotcha.
@alionking1023
@alionking1023 4 жыл бұрын
_Me after finishing my hw in the detention room_ 3:14
@sujatakale1673
@sujatakale1673 4 жыл бұрын
Can u plz make a video showing all the special keywords that help u code so quickly?
@aarushprasad4493
@aarushprasad4493 2 жыл бұрын
Not surprised if Amazon Music sues Cherno for uncaptioning the sponsorship section of the video.
@mrprick7183
@mrprick7183 6 жыл бұрын
Why does your hair look so different every video.
@carbonsx3
@carbonsx3 4 жыл бұрын
Implemented with a random seed... :D
@ScorpioHR
@ScorpioHR 3 жыл бұрын
I'm not here for programming tutorial. I'm waiting for the chicken to move!
@RenkoGSL
@RenkoGSL 3 жыл бұрын
Thank you so much for saying that about music.
@luciaveldera8305
@luciaveldera8305 3 жыл бұрын
Hi Cherno, I have a question about the meaning of this statement: const char* message. Why did you use pointer? Can we use "string message" instead of this statement?
@vikinggeorge7007
@vikinggeorge7007 2 жыл бұрын
6:40 - I would've used an enum
@abdulmoizsheikh8031
@abdulmoizsheikh8031 7 жыл бұрын
Yoooo, thanks for the tutorial. How old are you mate?
@entity5209
@entity5209 4 жыл бұрын
3:12 legit me eveytime I start coding
@РоманКапуста-в1о
@РоманКапуста-в1о 7 жыл бұрын
Thanks for the video Could u create some video explanation for objects initialization in C++, coz afaik there are bunch of this. Thanks
@rarespauna2817
@rarespauna2817 2 жыл бұрын
Why we used a pointer for the message variable ?
@iainsmith2026
@iainsmith2026 3 жыл бұрын
I'm kind of confused about everything you said after 3:30
@AlainDjiZ
@AlainDjiZ 6 ай бұрын
thank you bro
@websurfer5283
@websurfer5283 6 жыл бұрын
In this code: void Error(const char* message) . What does the * mean exactly. I know it's a pointer but what purpose has (const char* message) for this tutorial if anyone can explain. Thanks. I have been going through all the videos by the way. So I have covered the pointer video previously.
@levanfirtskhalava3836
@levanfirtskhalava3836 6 жыл бұрын
it,s purpose is to pass the variable not value but by the address. this function by the argument get char pointer, address not value
@lopost07
@lopost07 6 жыл бұрын
It's a bit more complicated with char pointers as you noticed from the video you can pass string to functions that takes const char* but why is this possible if it's a pointer? This is called string literal, so behind the scenes memory with this series of characters is allocated somewhere and passed as normal pointer which it is. Hope that helps
@escapeenrique
@escapeenrique 4 жыл бұрын
i really like this hairstyle
@adamhendry945
@adamhendry945 Жыл бұрын
Can you please do a video on pIMPL idiom/method?
@Grynjolf
@Grynjolf 6 жыл бұрын
Instead of using the "m_" prefix what are your opinions on using `this->`?
@lucasmorais3694
@lucasmorais3694 6 жыл бұрын
U can use it but is not the best method.
@JanithHarinda
@JanithHarinda 4 жыл бұрын
If you really learn something turn the speed to 0.75 but this guy is awsome
@preritvishal
@preritvishal 4 жыл бұрын
I turn to 1.50x ..... Is that okay? 😂
@gunrunjk
@gunrunjk 7 жыл бұрын
What is optimized method using different concept? I really wonder how does it work. Do you have a plan to create a video in order to keep continue next video?
@Mr_636
@Mr_636 3 жыл бұрын
I know I am late to the course, but as I learn a new language I like to try and explore new options as I learn. in doing so I found a way to simplify code a little bit. I shortened it by about 13 lines! #include class Log { public: const int LogLevelError = 0; const int LogLevelWarning = 1; const int LogLevelInfo = 2; private: int m_LogLevel = LogLevelError; public: void SetLevel(int level) { m_LogLevel = level; } void MessageLog(const char* msg, int level) { if (m_LogLevel == LogLevelError && m_LogLevel == level) std::cout
@xtiooplus
@xtiooplus 2 жыл бұрын
Yes, it works and I also find it very good to do something like this for practice. But I also think that this code is NOT understandable in one look and therefore it is bad code. Rule: Optimize code only where it matters
@dariodusper7068
@dariodusper7068 5 жыл бұрын
Why you are not dereferencing message at cout? Because without dereferencing you print out the address stored in the pointer. That's how you explained it in your video about pointers.
@npc6924
@npc6924 7 жыл бұрын
log.SetLevel() ------^------------ Is the standard different from Java? Am I thinking too much into it?
@Cynokine
@Cynokine 7 жыл бұрын
I noticed this too. Maybe this will be detailed in the future and was done on educational purpose here.
@sablanex
@sablanex 7 жыл бұрын
It's just a matter of preference I'd say, but the win32 api has the first letter capitalized in functions.
@edtExodus
@edtExodus 7 жыл бұрын
There is no standard notation in C++, though the standard reserves some specific notations (things like the double underscore, which you shouldn't be using). In the end it's about what works best for you and as long as you're consistent with it, other programmers will not find it terribly difficult to adapt to your code. Consistency is a lot more important than what exact notation you use.
@codehorse8843
@codehorse8843 5 жыл бұрын
This is a godsend
@myownthoughts969
@myownthoughts969 4 жыл бұрын
I’m having trouble with constant and regular variables. And pointers. And destructors... a lot of things that confuse me is the fact that the app I. Useing to learn code always uses the same words for classes and everything else in each program.. I need some sense of what the code I’m writing will be used for and how it would look like In real life.... never mind just realized this video is over 3 years old.
Static in C++
6:29
The Cherno
Рет қаралды 462 М.
Templates in C++
17:58
The Cherno
Рет қаралды 609 М.
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Stack vs Heap Memory in C++
19:31
The Cherno
Рет қаралды 587 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 315 М.
Compilers, How They Work, And Writing Them From Scratch
23:53
Adam McDaniel (kiwi)
Рет қаралды 241 М.
CLASSES vs STRUCTS in C++
8:32
The Cherno
Рет қаралды 484 М.
Macros in C++
19:36
The Cherno
Рет қаралды 244 М.
Function Pointers in C++
12:41
The Cherno
Рет қаралды 400 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 850 М.
Emulating a CPU in C++ (6502)
52:28
Dave Poo
Рет қаралды 1 МЛН
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН