C++ CONSTRUCTORS explained easy 👷

Поділитися
Вставка
  • Опубліковано 7 лют 2025
  • #constructor #tutorial #explained
    C++ constructor tutorial example explained

КОМЕНТАРІ • 30

  • @BroCodez
    @BroCodez  2 роки тому +23

    #include
    class Car{
    public:
    std::string make;
    std::string model;
    int year;
    std::string color;
    Car(std::string make, std::string model, int year, std::string color){
    this->make = make;
    this->model = model;
    this->year = year;
    this->color = color;
    }
    };
    int main() {
    //constructor = special method that is automatically called when an object is instantiated
    // useful for assigning values to attributes as arguments
    Car car1("Chevy", "Corvette", 2022, "blue");
    Car car2("Ford", "Mustang", 2023, "red");
    std::cout

    • @lv3234
      @lv3234 8 місяців тому +1

      am i tripping? why is this comment 1 year old but the video was posted 2 weeks ago

    • @draftofspasiba2
      @draftofspasiba2 7 місяців тому +1

      ​@@lv3234the video was unlisted/private before, after you make it public it will then set a new video date, except for comments.

    • @muntahmahfuzsrestho.
      @muntahmahfuzsrestho. 3 місяці тому

      I am seeing this too! 😮
      The video is 6 months old but this comment and some comments ar 2 years old. 😳​@@lv3234

  • @misaelsandoval7542
    @misaelsandoval7542 2 роки тому +5

    Great video!

  • @esraafadul2929
    @esraafadul2929 7 місяців тому +36

    can you make a vid about the destructors as well 😔, ty

  • @artemzakharchuk2842
    @artemzakharchuk2842 Рік тому

    Great lesson❤❤❤
    Broooo...🎉🎉🎉

  • @DetCoAnimeFan
    @DetCoAnimeFan 2 роки тому +3

    Great!

  • @HunaBopa
    @HunaBopa Рік тому

    Great lesson.

  • @bluefyr22
    @bluefyr22 3 місяці тому

    Love the break down. Clear and helpful

  • @3seczzzzz
    @3seczzzzz 3 місяці тому

    That was perfect❤

  • @shervin9561
    @shervin9561 Рік тому

    Thanks

  • @shadmankhan1969
    @shadmankhan1969 2 роки тому +1

    thx bro

  • @AnantaAkash.Podder
    @AnantaAkash.Podder 6 місяців тому

    Thank you sir😃

  • @atuhaireedwin3522
    @atuhaireedwin3522 Місяць тому

    Please one on vectors and how to use them

  • @feedertayfa8745
    @feedertayfa8745 18 днів тому

    can we use different statements in constructers like in c# and java or just can initialize the variables

  • @AozenDreyar
    @AozenDreyar Рік тому

    thank you

  • @gamsterilyass2952
    @gamsterilyass2952 7 місяців тому

    ❤❤❤❤

  • @Esau-d3h
    @Esau-d3h 5 місяців тому +1

    How do you add methods to a constructer

  • @MindMatrixx1416
    @MindMatrixx1416 7 місяців тому +2

    one night before semester exam 💀💀

  • @Sayne808
    @Sayne808 5 місяців тому +3

    class game{
    public:
    std::string gamename;
    int releasedate;
    game(std::string playername,int releasedate){
    this->playername=playername;
    this->releasedate=releasedate;
    }
    };

  • @samsrec6060
    @samsrec6060 8 місяців тому

    Create tutorial for golang

  • @Dazza_Doo
    @Dazza_Doo 2 роки тому +3

    Wow another thing C++ does better than C#
    Why do I say that?
    C++ () standard brackets
    C# {} used in a new constructor

  • @aashishraj187
    @aashishraj187 5 місяців тому +1

    include namespace std;
    class Jatt {
    public:
    string Name;
    string birthplace;
    string height;
    Jatt(string Name, string birthplace, string height){
    this->Name=Name;
    this->birthplace=birthplace;
    this->height=height;}
    };

  • @majanicse
    @majanicse Місяць тому

    Bro patrick is not 40😢

  • @danaildoganov
    @danaildoganov 10 місяців тому +2

    #include
    class Dish{
    public:
    int calories;
    std::string ingridients;
    int protein;
    std::string taste;
    Dish(int calories, std::string ingridients, int protein, std::string taste){
    this->calories = calories;
    this->ingridients = ingridients;
    this->protein = protein;
    this->taste = taste;
    }
    };
    int main(){
    Dish macandcheese(800, "Mac and Cheese", 50, "Yummy");
    std::cout

  • @AYSMOKASHI
    @AYSMOKASHI Рік тому +2

    #include
    class Car{
    public:
    std::string brand = "Vehicle";
    std::string model = "Model";
    int year;
    void drive(){
    std::cout