What mistakes have you made? Be notified of new C/C++ course: calcur.tech/c-cpp-newsletter
@joonyou939210 ай бұрын
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
@Chevifier10 ай бұрын
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.
@BigJMC9 ай бұрын
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 Жыл бұрын
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 Жыл бұрын
Try asking ChatGPT maybe?
@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 Жыл бұрын
@@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 Жыл бұрын
@@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 Жыл бұрын
Number one mistake; learning c++. 😂jk jk
@knofi7052 Жыл бұрын
The biggest mistake is learning C++ in the first place!😂 Just learn C instead!😉
@mimix.v Жыл бұрын
But what about OOP =)
@nickton Жыл бұрын
But C is so bad...
@Shreyas_Jaiswal7 ай бұрын
@@nicktonbut it's c++ dad
@PiotrPilinko6 ай бұрын
"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.