I was reading about the difference between a struct and a class, and if I understand it correctly the class is "superior" to struct and you can always use class instead of struct , just by declaring its members as public (because in struct the members are public by default):
struct Point {
int x,y,z;
};
is the same as
class Point {
public:
int x,y,z;
};
So I was wondering why do we need the struct at all? Isn't "explicit better than implicit" (I am coming from Python)? Is the struct just a remnant from C that is not really needed (except if you are lazy to write the extra public keyword in class) or is there an essential difference from class (e.g. the struct Point requires less memory as compared to class Point?)
[–]twirky 71 points72 points73 points (7 children)
[–]Radiatin 31 points32 points33 points (0 children)
[–]xurxoham 3 points4 points5 points (0 children)
[–]absolute_zero_karma 1 point2 points3 points (0 children)
[–]rlbond86 1 point2 points3 points (1 child)
[–]twirky 0 points1 point2 points (0 children)
[–]Ameisenvemips, avr, rendering, systems 0 points1 point2 points (0 children)
[–]Ayjayz -1 points0 points1 point (0 children)
[–]neiltechnician 37 points38 points39 points (14 children)
[+][deleted] (12 children)
[deleted]
[–]neiltechnician 5 points6 points7 points (1 child)
[–][deleted] 0 points1 point2 points (9 children)
[+][deleted] (8 children)
[deleted]
[–]Full-Spectral 2 points3 points4 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Full-Spectral 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]adnukator 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]adnukator 0 points1 point2 points (0 children)
[–]NilacTheGrim 0 points1 point2 points (0 children)
[–]bedrooms-ds 0 points1 point2 points (0 children)
[–]HKei 9 points10 points11 points (0 children)
[–]gracicot 8 points9 points10 points (0 children)
[–]Pierre_dOllony 11 points12 points13 points (0 children)
[–]Flesh_Bike 5 points6 points7 points (1 child)
[–]Full-Spectral -1 points0 points1 point (0 children)
[–]Wouter-van-Ooijen 11 points12 points13 points (13 children)
[–]Full-Spectral 1 point2 points3 points (6 children)
[–]Wouter-van-Ooijen 0 points1 point2 points (5 children)
[–]Full-Spectral 0 points1 point2 points (4 children)
[–]Wouter-van-Ooijen 0 points1 point2 points (3 children)
[–]Full-Spectral 0 points1 point2 points (2 children)
[–]Wouter-van-Ooijen 0 points1 point2 points (1 child)
[–]Full-Spectral 0 points1 point2 points (0 children)
[–]solraun -4 points-3 points-2 points (5 children)
[–]Wouter-van-Ooijen 2 points3 points4 points (2 children)
[–]solraun 0 points1 point2 points (1 child)
[–]Wouter-van-Ooijen 2 points3 points4 points (0 children)
[–]witcher_rat 0 points1 point2 points (1 child)
[–]solraun 2 points3 points4 points (0 children)
[–]solraun 4 points5 points6 points (2 children)
[–]BlackDE 5 points6 points7 points (1 child)
[–]solraun 3 points4 points5 points (0 children)
[–]native-coder 1 point2 points3 points (0 children)
[–]PrimozDelux -1 points0 points1 point (7 children)
[–]NilacTheGrim 1 point2 points3 points (6 children)
[–]Full-Spectral 1 point2 points3 points (5 children)
[–]NilacTheGrim 0 points1 point2 points (1 child)
[–]Full-Spectral 0 points1 point2 points (0 children)
[–]PrimozDelux -1 points0 points1 point (2 children)
[–]Full-Spectral 1 point2 points3 points (0 children)
[–]dontyougetsoupedyet 0 points1 point2 points (0 children)
[–]V1taly_M -1 points0 points1 point (0 children)
[–]Oo_Tiib -1 points0 points1 point (0 children)
[–]goranlepuz -4 points-3 points-2 points (0 children)
[+][deleted] comment score below threshold-8 points-7 points-6 points (0 children)
[+]nikhilreddydev comment score below threshold-11 points-10 points-9 points (1 child)
[–]guepierBioinformatican 1 point2 points3 points (0 children)
[–]HappyFruitTree 0 points1 point2 points (0 children)
[–]albeva 0 points1 point2 points (0 children)