Thomas Hruska <thru...@...> wrote:
> peternilsson42 wrote:
> > I've never understood why people don't declare classes...
> > 
> >   struct student
> >   {
> >     student();
> >     ~student() { cout << "i am destructor" << endl; }
> >     void setvalue(const char *);    
> >     void display() const;
> > 
> >   private:
> >     char name[50];
> >     int stunum;
> >   };
> 
> Because it looks weird?

It seems intuitively obvious to me. :-) You don't put the
stuff you want to hide (or restrict access to) first!

> To mentally differentiate my C background from C++,
> 'struct' = data storage only (even though I know otherwise),
> and 'class' = member functions and data storage.

In C++ (not that I do much of it,) I read struct and class as
the same keyword. The difference is simply the default access
specifier. I've always wondered why the default access
specifier for class was private. Never bothered looking into
it though.

-- 
Peter

Reply via email to