C++ Programming Tutorial 96 - Class Across Files - Multifile Compilation

Поделиться
HTML-код
  • Опубликовано: 20 мар 2019
  • Start your software dev career - calcur.tech/dev-fundamentals 💯 FREE Courses (100+ hours) - calcur.tech/all-in-ones
    🐍 Python Course - calcur.tech/python-courses
    ✅ Data Structures & Algorithms - calcur.tech/dsa-youtube
    ~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~
    ✉️ Newsletter - calcur.tech/newsletter
    📸 Instagram - / calebcurry
    🐦 Twitter - / calebcurry
    🔗 LinkedIn - / calebcurry
    ▶️ Subscribe - calcur.tech/subscribe
    👨🏻‍🎓 Courses - www.codebreakthrough.com
    ~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~
    ↪ My Amazon Store - www.amazon.com/shop/calebcurry
    🅿 Patreon - calcur.tech/patreon-calebcurry
    🅖 GitHub Sponsors - github.com/sponsors/CalebCurry
    Ⓟ Paypal - paypal.me/calcur
    🅑 Bitcoin - 3HnF1SWTzo1dCU7RwFLhgk7SYiVfV37Pbq
    🅔 Eth - 0x350139af84b60d075a3a0379716040b63f6D3853
    📈 Buy Bitcoin - calcur.tech/crypto
    Reserve the Ruby Steel crypto rewards card and get a $25 bonus (use affiliate code "Caleb") - calcur.tech/crypto
  • НаукаНаука

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

  • @PunmasterSTP
    @PunmasterSTP 2 года назад +4

    Class across files? I certainly think that you have it, as all of these videos have been superb! Thanks again for making them, and I completely intend to start another tutorial series (possibly Java or Python) immediately once I finish this one...

  • @ianq0101
    @ianq0101 3 года назад +3

    I know this is a debatable issue, but I have to ask: Is it best to put all #include statements in the header file, or have them in the .cpp files?
    In my example, I need includes in both my main and class .cpp files, and I need in my header file. Is it not better to just put all the includes in the header file instead of having them in both my cpp files as well as one in my header file? Maybe this is my C programming habits coming out! Thx...Ian

  • @sanfarans
    @sanfarans 3 года назад +1

    thank you so much

  • @badhairdaytoday
    @badhairdaytoday 9 месяцев назад

    Thank you so much!!!

  • @Ethan-po8ji
    @Ethan-po8ji Год назад

    the vscode theme looks nice

  • @123userthatsme
    @123userthatsme Год назад

    How about if you have a class that needs to inlcude another class?
    I've got an Organizer class that needs to be initiated with an array of Slot's. It doesn't like it when I include Slot from main ("Slot is not a type name") or if I don't ("Expected initializer before allSlots").

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

    You could also use _#pragma__ once_ instead of the #ifndef magic words.

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

    I use xcode. Anyone know how to resolve the following error? "2 duplicate symbols for architecture x86_64"
    I have a main.cpp, 2 .cpp + 2 .h files for class declarations & definitions, and 1 .h for enumeration. Any insight is appreciated! Thanks!

  • @n.g.9705
    @n.g.9705 4 года назад +1

    Do you generally not use the key word "class" or class name in the .cpp file when you separate it from the declaration .h file? Just definitions and declarations in separate files?

    • @anthonystevens6999
      @anthonystevens6999 2 года назад

      you do not need to use the key word "class" in the .cpp (implementation) file.

  • @cafelashowerezweb
    @cafelashowerezweb 4 года назад +4

    still hard to understand why "static" is deleted... can anyone explain about it?

    • @ReddoX30
      @ReddoX30 4 года назад +5

      I will try to explain: the variable has already been declared static in the header file so the compiler knows it's a static member. That's why we don't need to specify that it's static again in the user.cpp file.
      Hope that clears things up:)

  • @jaimecarranza2509
    @jaimecarranza2509 2 месяца назад

    1:42 .h contains the declaration class_name.cpp contains the definition. Thanks

  • @donato685
    @donato685 2 года назад

    I need help. Are 2 days I'm trying to repeating this exercise, but it doesn't compile. Is the written code available?

  • @TheMessinho1000
    @TheMessinho1000 4 года назад

    I prefer creating a makefile for multiple file compilation. But I have a problem with debugging. It throws an error like "undefined reference" . If I include the implementation file(.cpp) in main.cpp, then the problem goes away. But I want to know if there is another way to fix this. Can you help me ?

    • @maxdegreat566
      @maxdegreat566 2 года назад

      please tell me how did you fic this im stuck on it rn too
      and this is due today at 11:59 ...

  • @cyan_28
    @cyan_28 2 года назад +1

    What's your vscode theme?

  • @mayankk104
    @mayankk104 3 года назад +2

    how to implement templated class sepration ???

  • @Jackaldev
    @Jackaldev 4 года назад +12

    69 lines and it's the 96th episode ;)

  • @JVenom_
    @JVenom_ 3 года назад +1

    me coming from java where we can just say "import {class name here}"; and be done...

    • @mhn2500
      @mhn2500 2 года назад +1

      Me comming from python and having to do more things than c++, while python is supposed to be an easier language

    • @breadpebbles2603
      @breadpebbles2603 2 года назад

      @@mhn2500 you just do import 'filename.oi' or import library

  • @dimitardime1123
    @dimitardime1123 4 года назад +2

    Hehe "big 69 line code" 69 nice

  • @basicallybrand
    @basicallybrand 2 года назад

    That's very time consuming. python and java is generates these files. I didn't c++ was this bad