C++ CONSTRUCTORS explained easy 👷

แชร์
ฝัง

ความคิดเห็น • 23

  • @BroCodez
    @BroCodez  2 ปีที่แล้ว +15

    #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 3 หลายเดือนก่อน

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

    • @draftofspasiba2
      @draftofspasiba2 3 หลายเดือนก่อน

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

  • @esraafadul2929
    @esraafadul2929 2 หลายเดือนก่อน +10

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

  • @DetCoAnimeFan
    @DetCoAnimeFan 2 ปีที่แล้ว +3

    Great!

  • @Sayne808
    @Sayne808 หลายเดือนก่อน +1

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

  • @misaelsandoval7542
    @misaelsandoval7542 2 ปีที่แล้ว +5

    Great video!

  • @aashishraj187
    @aashishraj187 19 วันที่ผ่านมา

    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;}
    };

  • @Esau-d3h
    @Esau-d3h 22 วันที่ผ่านมา

    How do you add methods to a constructer

  • @shadmankhan1969
    @shadmankhan1969 2 ปีที่แล้ว +1

    thx bro

  • @Dazza_Doo
    @Dazza_Doo ปีที่แล้ว +3

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

  • @MindMatrixx1416
    @MindMatrixx1416 3 หลายเดือนก่อน

    one night before semester exam 💀💀

  • @samsrec6060
    @samsrec6060 4 หลายเดือนก่อน

    Create tutorial for golang

  • @AnantaAkash.Podder
    @AnantaAkash.Podder หลายเดือนก่อน

    Thank you sir😃

  • @danaildoganov
    @danaildoganov 6 หลายเดือนก่อน +1

    #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

  • @artemzakharchuk2842
    @artemzakharchuk2842 11 หลายเดือนก่อน

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

  • @AozenDreyar
    @AozenDreyar 8 หลายเดือนก่อน

    thank you

  • @shervin9561
    @shervin9561 9 หลายเดือนก่อน

    Thanks

  • @HunaBopa
    @HunaBopa 11 หลายเดือนก่อน

    Great lesson.

  • @gamsterilyass2952
    @gamsterilyass2952 2 หลายเดือนก่อน

    ❤❤❤❤

  • @AYSMOKASHI
    @AYSMOKASHI 8 หลายเดือนก่อน +1

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