[chbot] Programming 8-bit microcontrollers

Charles Manning cdhmanning at gmail.com
Mon Sep 26 20:08:38 BST 2016


One of the reasons I dislike C++.... It looks like C, but it isn't.

IIRC, struct in C++ is exactly the same as class except struct is default
public while
class is default private. ie structs can have member functions, inheretance
etc.

However, by convention, struct should only be used for "dumb" C style
structures and class for everything else. Public flogging for anyone that
inherits from a struct or adds member functions.



On Mon, Sep 26, 2016 at 10:59 PM, Paul Davey <plmdvy at gmail.com> wrote:

> On Mon, Sep 26, 2016 at 3:47 PM, Volker Kuhlmann
> <list0570 at paradise.net.nz> wrote:
> snip
> >
> > Paul I don't know if the aggregate initialisation works for private
> > members (it should), the class should still be assignable, privates
> > included. But yes I stripped down 1 line too many, and it should be
> >
> >    class values {
> >      public:
> >        ...
> >
>
> C++ has a bunch of rules for when you can use a class/struct like a C
> struct, one of them is it must have no non-public members, also no non
> trivial constructors or destructors and a few other things, I got that
> restriction by looking here
> http://en.cppreference.com/w/cpp/language/aggregate_initialization.


> Also the point about not caring about how few members you give to the
> initialiser is inherited from C which will just 0 any fields not
> given.
>
> Cheers,
> Paul
>
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.linuxnut.co.nz
> http://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Meetings usually 3rd Monday each month. See http://kiwibots.org for
> venue, directions and dates.
> When replying, please edit your Subject line to reflect new subjects.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20160927/746bfe3c/attachment.html>


More information about the Chchrobotics mailing list