Video není dostupné.
Omlouváme se.

C++ Typedef and type aliases explained 🙋‍♂️

Sdílet
Vložit
  • čas přidán 18. 05. 2024
  • #typedef #using
    // Typedefs and type aliases
    // typedef = reserved keyword used to create an additional name
    // (alias) for another data type.
    // New identifier for an existing type
    // Helps with readability and reduces typos
    // Use when there is a clear benefit
    // Replaced with 'using' (work better w/ templates)

Komentáře • 73

  • @BroCodez
    @BroCodez  Před 2 lety +11

    #include
    //typedef std::string text_t;
    //typedef int number_t;
    using text_t = std::string;
    using number_t = int;
    int main(){
    text_t firstName = "Bro";
    number_t age = 21;
    std::cout

    • @BasPower12
      @BasPower12 Před 10 měsíci

      I have an error that says conversation from 'int' to non scalar type 'number_t' {aka 'std::__cxx11::basic_string'}

    • @BasPower12
      @BasPower12 Před 10 měsíci

      I'm using VS code BTW

  • @nuamanshabir6122
    @nuamanshabir6122 Před rokem +1

    I always used to use typedef for renaming structures when i was learning DSA basics in Clanguage, it just made the declarations of node pointers so easy.Great video mate🥰🥰

  • @moikennersan1804
    @moikennersan1804 Před 2 lety +18

    Man why you have so few views? you deserve more views

    • @areotaco5044
      @areotaco5044 Před 2 lety +3

      Right? I'm guessing because it's a brand new series. He also has this video unlisted though so that's def tanking his viewership.

    • @clydebaldassare2387
      @clydebaldassare2387 Před rokem

      @@areotaco5044 By any chance in the 5 months are you at least ok in c++?

    • @Scriptedsyntax
      @Scriptedsyntax Před rokem

      @@clydebaldassare2387 how ab you my friend? are you at least “Good” at c++ in 4 months?

    • @retardbuster1498
      @retardbuster1498 Před měsícem

      Because most of the viewers never leave likes and comments and even subscribe.

  • @GlobalGymMusic
    @GlobalGymMusic Před 27 dny +1

    Older Bro: "Are you using typedef?" ☹
    Younger Bro: "No, bro. I am using using." 🙂

  • @vedsur8610
    @vedsur8610 Před rokem +4

    I'll use both versions of syntax. If I want to to call double float_t, I'll do it these two ways.
    // First way
    typedef double float_t;
    // Second way
    using float_t = double;

  • @yellowhellow-wi9gi
    @yellowhellow-wi9gi Před 25 dny

    thank youu

  • @masterofcraftmoc827
    @masterofcraftmoc827 Před rokem +2

    Do C++ they said, it's easy as python they said, no confusion whatsoever they said.

  • @KrimsonKloud
    @KrimsonKloud Před 2 měsíci +1

    I copied your code and it didn't work. I got several error messages, some saying 'expected nested-name-specifier before text_t and number_t'. Also saying its not declared. Wtf.

  • @JayadevNarayanan-ug1vx

    Bro this happens when I try to use using.
    using.cpp:8:15: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
    using xt= std::string;
    ^
    1 warning generated.
    Any fixes? Tried many online, nothing works.

  • @kumotheeduck7297
    @kumotheeduck7297 Před 2 měsíci

    It says it was posted 2 days ago but has comments from a year ago?

  • @MNKY-xe3du
    @MNKY-xe3du Před měsícem

    I tried "using op_t = std::cout;" but it did not work for some reason,
    can someone say why

  • @PyaeSone-iu2pt
    @PyaeSone-iu2pt Před 2 lety

    Hey bro what's your extensions and terminal? I want to use. And please let me know how to set up

    • @USERGFD
      @USERGFD Před rokem

      just create a new document and name in file.cpp

  • @armomations5712
    @armomations5712 Před rokem +1

    typedef int cheese_t;
    using cheese_t = int;

  • @engineeringmania9125
    @engineeringmania9125 Před rokem +2

    typedef double decimal_num;
    using decimal_num = double;

  • @BaraBarabere.
    @BaraBarabere. Před rokem

    Is it complete course or just for beginners?

    • @kitara_69
      @kitara_69 Před rokem

      Just for beginners, I saw intermediate and expert tutorials online. TT

  • @zdofficial3740
    @zdofficial3740 Před 3 měsíci

    why cant we use typedef std::cout out_t

  • @costi2m
    @costi2m Před rokem

    //double num = 3.5;
    //typedef double decimal_t;
    using decimal_t = double;
    decimal_t num = 3.5;
    std::cout

  • @ryanalnaser914
    @ryanalnaser914 Před rokem

    whatever anything before or after

  • @artemzakharchuk2842
    @artemzakharchuk2842 Před 9 měsíci +1

    First way: typedef std::string text_t ; Second way: using numbers_t = int;

  • @Yousif_Maksabo
    @Yousif_Maksabo Před měsícem

    using state_t = bool;
    int main() {
    state_t switch = true;
    return 0;
    }

  • @user-jl5de4qf7g
    @user-jl5de4qf7g Před 2 lety +2

    I copy the code but I get not declared in this scope error and expected nested name specifer error

    • @11.nguyenhongdien58
      @11.nguyenhongdien58 Před rokem

      i also have the same error with you

    • @Dazza_Doo
      @Dazza_Doo Před rokem

      what code did you copy? Also, don't copy code, type it out

  • @akeem3127
    @akeem3127 Před rokem +1

    typedef std::string stringA;
    typedef int intergerA;
    using stringB = std::string;
    usinng integerB = int;

  • @octaviangoga4027
    @octaviangoga4027 Před 11 měsíci

    #include
    typedef double float_t;
    int main(){
    float_t height = 1.89;
    std::cout

  • @eternaldarkbrin
    @eternaldarkbrin Před měsícem

    using text_t = std::string;
    int main() {
    text_t sprinkles = "Pringles";
    std::cout

  • @Enbroard_E
    @Enbroard_E Před 13 dny

    wanted to see if it could work with name spaces and it worked:
    #include
    using number_t = int;
    namespace first{ //Number 1
    number_t x = 1;
    }
    namespace second{ //Number 2
    number_t x = 2;
    }
    int main() {
    number_t x = 0; //Number 0
    std::cout

  • @NotMarsh
    @NotMarsh Před rokem

    #include
    using number = double;
    int main()
    {
    number amogus = random();
    std::cout

  • @vmook655
    @vmook655 Před 3 měsíci

    using desimal_t = double;
    int main() {
    desimal_t verdi = 3.5;
    std::cout

    • @talenium
      @talenium Před 2 měsíci

      dont forget to add #include

  • @FaneleNkosi-lj9vz
    @FaneleNkosi-lj9vz Před 26 dny

    using Num = std::int;
    Num = 4;
    std::cout

  • @flamemotholic1209
    @flamemotholic1209 Před rokem

    #include
    #include
    typedef std::string message;
    int main() {
    message name = "Bro";
    std::cout

  • @tee-hee9553
    @tee-hee9553 Před rokem +5

    it's more easy than python🤣🤣

    • @lolman6976
      @lolman6976 Před rokem +2

      yea its only the include io stream and return 0 that makes people go crazy lol

    • @kvsbcsljv
      @kvsbcsljv Před 6 měsíci

      ​@@lolman6976wait until bro discovers pointers

  • @ItsAstreo
    @ItsAstreo Před 7 měsíci

    using doub_t = double;

  • @zai01123
    @zai01123 Před 6 měsíci

    using float_t = double ;

  • @Dazza_Doo
    @Dazza_Doo Před rokem +2

    typedef std::cout Print

  • @sztamjan866
    @sztamjan866 Před 4 měsíci

    typedef int integer;

  • @zai01123
    @zai01123 Před 6 měsíci

    using HH = bool;

  • @zai01123
    @zai01123 Před 6 měsíci

    typedef double float_t ;
    typedef bool tf_t

  • @vedhriyer
    @vedhriyer Před rokem

    using hi = bool;

  • @SudiptaBadhon
    @SudiptaBadhon Před 26 dny

    Typedef std::string name_t;
    Using name_t = std::string;
    Int main(){
    name_t firstname= "bro";
    cout

  • @code-charm-linux
    @code-charm-linux Před 3 měsíci

    typedef float decimal_t;

  • @LocoCoco15
    @LocoCoco15 Před 6 měsíci

    typedef double double_d;
    using double_d = double;
    double_d gravity = 9.8;
    std::cout

  • @Yami575
    @Yami575 Před 21 dnem

    #include
    typedef int number_t ;
    typedef std::string text_t;
    int main() {
    number_t age = 5;
    text_t LastName = "Among";
    std::cout

  • @kartikchauhan5209
    @kartikchauhan5209 Před rokem

    using str = std::string ;

  • @azerty7118
    @azerty7118 Před rokem

    typedef std::string text_t;
    using liczba_t = int

  • @kamachan1230
    @kamachan1230 Před 3 měsíci

    typedef struct {
    int score1;
    int score2;
    } grade;
    int main() {
    grade student1, student2;

  • @JayadevNarayanan-ug1vx

    typedef std::string ni;
    ni tx="heyy";

  • @nwaforty
    @nwaforty Před 6 měsíci

    using print = std::cout
    typedef std::cout print;

  • @kitara_69
    @kitara_69 Před rokem

    #include
    using std::cout;
    using std::endl;
    typedef std::string mes_t;
    typedef float fl_t;
    int main(){
    mes_t name = "James";
    fl_t bodyTemp = 36.5;
    cout

  • @gusgus1330
    @gusgus1330 Před 6 měsíci

    typedef int num_t;
    typedef double decimal_t;
    using string_t = std::string;
    using letter_t = char;
    int main()
    {
    num_t catLives = 9;
    std::cout

  • @yashhengne3056
    @yashhengne3056 Před 5 měsíci

    typedef std::string lol_t;

  • @user-dg9qf1xj7l
    @user-dg9qf1xj7l Před 7 měsíci

    typedef std::endl endl;
    typedef std::cout cout;
    typedef std::cin cin;

  • @kareemparris7757
    @kareemparris7757 Před 2 lety

    typedef std::string word;

    • @teagleh
      @teagleh Před 2 lety

      why not str

    • @oximas-oe9vf
      @oximas-oe9vf Před rokem +4

      @@teagleh because you are free to do whatever you want🙃

  • @roidoP
    @roidoP Před rokem

    #include
    using quote_t = std::string;
    int main() {
    quote_t Quote = "Meron ka bang lemon? Gusto ko tequila!";
    std::cout

  • @nguyenxongphi
    @nguyenxongphi Před 9 měsíci

    #include
    typedef std::string cnmeo_t;
    typedef float oatdoheo_t;
    int main ()
    {
    cnmeo_t ten="cn cak";
    std::cout

  • @nofall4263
    @nofall4263 Před rokem

    using f_t = bool;
    int main(){
    f_t q; = true;
    std::cout