Learning C++? Avoid these Beginner Mistakes...

  Рет қаралды 6,653

Caleb Curry

Caleb Curry

Күн бұрын

Пікірлер: 17
@codebreakthrough
@codebreakthrough Жыл бұрын
What mistakes have you made? Be notified of new C/C++ course: calcur.tech/c-cpp-newsletter
@Wilderlens
@Wilderlens Ай бұрын
You can also instantiate an initialized object, with the compiler generated default constructor, by using or assigning empty braces in the declaration: Person p1{}; Person p1 = {}; Using the constructor initializer list is best practice tho, just remember that the order of the list must match the order of the class members.
@joonyou9392
@joonyou9392 Жыл бұрын
Correct me if I'm wrong but, I think putting an assignment inside an if condition isn't strictly "always" true, but I think it's more that in C++ any non-zero number is considered true, and the assignement operator "returns" the assigned value, thus it depends on the assigned value, if it's 0 it'd be false, otherwise it'd be to if(x = 0) { ‎ //do something } //always evaluates to false if(x = 96) { ‎ //do another thing } //always evaluates to true I know this doesn't change anything but I thought giving out an explanation to this phenomenon would help some people understand why this happens or is allowed
@Chevifier
@Chevifier Жыл бұрын
Been learning C++ for the past few months, any reason why you initialized age in the Person Constructor the way you did: Person() : age(0){//constructor stuff }; instead of doing: Person(){ age = 0; }; Its really confusing seeing it done interchangeably.
@BigJMC
@BigJMC 11 ай бұрын
The difference is efficiency, the first example you’re passing a member initializer, basically telling the program to construct the instance with the relevant values. (Basically like giving a blueprint of your house to construction workers and them building it based on that blueprint.) In the second part you’re basically telling program to construct the instance with a default constructor and then assign the relevant values to the variables. So in the second case your program might go and create a instance and set all the values to 0 or some default equivalent and then have to go back and reassign each variable with the relevant values as assigned in the constructor. (So basically telling the constructor workers to build a template house and then after completion telling them to change the rooms and renovate certain part of the house).
@only4posting
@only4posting Жыл бұрын
I've been having a weird issue with visual studio code, (mingw+gcc), with code runner + in tellisense(i think) installed. When i type some little code, i click on debug, it debugs fine, no errors. I then run it, and either the 'output' or 'terminal' will output the correct values. But then, no matter if i add some extra code or not, if i click again on 'debug', i immediately get an error, like 'no file permissions' ! I've checked everything... from install paths... files and folder permissions, etc etc, still the same result. One could think that the file, let's say, test03.exe, could be used, or could exist, somewhere, in the task or process list, and the compiler would simply not be able to overwrite the file... but when i get the error, the file doesn't even exist. Any idea ?
@shiv.shankar
@shiv.shankar Жыл бұрын
Try asking ChatGPT maybe?
@mackinator
@mackinator Жыл бұрын
Any file errors I get have generally been caused by using spaces in the file path. Spaces in any part of the path are a no go usually.
@only4posting
@only4posting Жыл бұрын
@@shiv.shankar done already. It talked about the file already existing in the task bar, and being locked by another process, like explorer.exe... but that wasn't the case. sounds like I'm going to install it on a VM, and mess with it until it works (or explodes :)
@shiv.shankar
@shiv.shankar Жыл бұрын
@@only4posting Ok. I have actually never debugged my code because it creates this json file and all that so i am actually terrified to do it. I will learn to debug after completing DSA
@Nathan00at78Uuiu
@Nathan00at78Uuiu Жыл бұрын
Number one mistake; learning c++. 😂jk jk
@knofi7052
@knofi7052 Жыл бұрын
The biggest mistake is learning C++ in the first place!😂 Just learn C instead!😉
@mimix.v
@mimix.v Жыл бұрын
But what about OOP =)
@nickton
@nickton Жыл бұрын
But C is so bad...
@Shreyas_Jaiswal
@Shreyas_Jaiswal 9 ай бұрын
​@@nicktonbut it's c++ dad
@PiotrPilinko
@PiotrPilinko 8 ай бұрын
"The more languages you know the more you are human" 😁 For me C is too primitive: c# (or even c++) allows to make a much better and robust code.
Smart Pointers in C++ (Stop Using new?)
17:18
Caleb Curry
Рет қаралды 15 М.
C++ Mistakes Noobs Make (and how to prevent them)
28:22
Colin Galen
Рет қаралды 21 М.
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН
References in C++ Explained
14:21
Caleb Curry
Рет қаралды 105 М.
C++ Pointers - Finally Understand Pointers
15:56
Caleb Curry
Рет қаралды 223 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 865 М.
Finally solve memory leaks in C++!
8:03
Low Level Game Dev
Рет қаралды 53 М.
C++ Weekly - Ep 404 - How (and Why) To Write Code That Avoids std::move
8:50
C++ Weekly With Jason Turner
Рет қаралды 35 М.
you will never ask about pointers again after watching this video
8:03
CppCon 2019: Jason Turner “The Best Parts of C++"
58:36
CppCon
Рет қаралды 92 М.
C++ Pointers to Pointers - Finally Understand Double Pointers
13:18
C Strings in 20 Minutes | C and C++
20:56
Caleb Curry
Рет қаралды 8 М.
No BS Advice for Software Engineers
1:21:17
Caleb Curry
Рет қаралды 56 М.
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН