CLASSES vs STRUCTS in C++



Twitter ► https://twitter.com/thecherno
Instagram ► https://instagram.com/thecherno
Patreon ► https://patreon.com/thecherno

Series Playlist ► https://www.youtube.com/playlist?list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb

BEST laptop for programming! ► http://geni.us/pakTES
My FAVOURITE keyboard for programming! ► http://geni.us/zNhB
FAVOURITE monitors for programming! ► http://geni.us/Ig6KBq

MAIN Camera ► http://geni.us/t6xyDRO
MAIN Lens ► http://geni.us/xGoDWT
Second Camera ► http://geni.us/CYUQ
Microphone ► http://geni.us/wqO6g7K

Slack ► https://slack.thecherno.com
Stream ► http://www.twitch.tv/thecherno
Website ► http://www.thecherno.com
Facebook ► http://www.facebook.com/thecherno

22 thoughts on “CLASSES vs STRUCTS in C++

  1. Gotta be honest. I've only ever used structs in C programming. Didn't even think about using them in C++. Good to know I wasn't missing anything.

  2. I wonder why I am getting LK2019 if I create a header for the class
    header file
    class Player {

    public:

    int x, y;

    int speed;

    void Move(int , int );

    };

    cpp file
    class Player {

    public:

    int x, y;

    int speed;

    void Move(int xa, int ya) {

    x += xa * speed;

    y += ya * speed;

    };

    };

    in main mail I have #onclude header file. If I include cpp file, no issue.

  3. I like to use structs inside unions to give the variables initial values without a constructor. If I used a class the extra public keyword makes it less of a one line solution.
    Structs in general I think look cleaner in unions tbh.

  4. Sooo basically EA/Activision would say they prefer classes set to mostly private, and whatever the artists needs to change that function would be set to public?
    i.e. changing roughness, ao, normals set to private will make it impossible for the artists to manipulate their work unless they know how to program.

  5. So I come mainly from Swift, where class and struct are two rather different things. But my idea of what the difference should be, based on my background in swift, is that a class has identity and a struct does not. So struct Point { x: Int; y: Int } does not have identity, because two points with identical x and y values are in every aspect, identical. If I return you one or the other it doesn't really matter. It's a value type essentially.
    A Player object: class Player { p: Point } even if it effectively holds the same data as the Point struct now effectively has identity when we think about it and will, in Swift, act as a reference type

  6. Im new to c++ so this might be a stupid question, but a method is basically nothing else than a function within a class or structure, right?

    Also: If you keep it really simple (by that i mean simple, as it would probably never ever be in "real" code) you could also substitute some classes with just functions, cant you? (void functions)

  7. If you REALLY want to learn a language , this is not the best channel. This one may only be good at terminology of some terms but then again, some other channels provide longer emphasis which is what you want, and not some fast video. This is good if you already sort of know the topic.

Leave a Reply

Your email address will not be published. Required fields are marked *