3 Replies - 343 Views - Last Post: 18 September 2009 - 07:35 PM Rate Topic: -----

#1 pesadilla143  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 21-May 08

Structures and Classes

Posted 18 September 2009 - 07:01 PM

Besides 'private' and 'public' being default, what is the difference between a class and a structure?

I know about classes having methods whereas structures don't.

Can you give me an example of when one is better than the other and vice versa.

ALSO

Doesn't mutators and accessors defeat the purpose of 'private'?
Is This A Good Question/Topic? 0
  • +

Replies To: Structures and Classes

#2 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3093
  • View blog
  • Posts: 19,139
  • Joined: 14-September 07

Re: Structures and Classes

Posted 18 September 2009 - 07:07 PM

Read Me

As for mutators/accessors, they allow an "interface" with the private members. It allows for easier bug hunting when values change to something you don't want or didn't expect. Allowing anything to access the data creates a multitude of possibilities and violates OOP principles.
Was This Post Helpful? 0
  • +
  • -

#3 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Structures and Classes

Posted 18 September 2009 - 07:08 PM

common topic these days.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6031
  • View blog
  • Posts: 23,414
  • Joined: 23-August 08

Re: Structures and Classes

Posted 18 September 2009 - 07:35 PM

School's in session, ya know? ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1