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

Поделиться
HTML-код
  • Опубликовано: 16 июл 2024
  • НаукаНаука

Комментарии • 17

  • @codebreakthrough
    @codebreakthrough  Год назад +3

    What mistakes have you made?
    Be notified of new C/C++ course: calcur.tech/c-cpp-newsletter

  • @joonyou9392
    @joonyou9392 6 месяцев назад +3

    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

  • @furkankaraslan9040
    @furkankaraslan9040 Год назад

    i got error msg when i was trying to use debugger but weird part is visual studio debugging only works under a certain directory how do i solve that problem any ideas? also since i started to use vsc compiler all exe files my c dev produces getting treatment like it is a virus from my firewall idk why

  • @Chevifier
    @Chevifier 6 месяцев назад +1

    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 4 месяца назад +3

      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 Год назад +1

      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 Год назад +4

    Number one mistake; learning c++. 😂jk jk

  • @knofi7052
    @knofi7052 Год назад +2

    The biggest mistake is learning C++ in the first place!😂 Just learn C instead!😉

    • @mimix.v
      @mimix.v Год назад +4

      But what about OOP =)

    • @nickton
      @nickton Год назад +1

      But C is so bad...

    • @Shreyas_Jaiswal
      @Shreyas_Jaiswal 3 месяца назад

      ​@@nicktonbut it's c++ dad

    • @PiotrPilinko
      @PiotrPilinko Месяц назад

      "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.