Thread: Hi, about Class and Objects

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    96

    Hi, about Class and Objects

    Hi,

    I have got a question, is it true that "Classes" that we use in C Program are replacement for "Structure"?

    Is their something wrong with "structure" that classes had to be introduced?

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    In C++, structs were extended to have member functions and access levels (private, protected, public), with a default access of public. The class construct, as far as I know, is just a kind of "syntactic sugar" for a struct that has default private access. So both struct and class define "classes", but programmers generally use struct for classes with public data members and class for classes with private data members.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 07-15-2010, 07:53 PM
  2. Array of class objects
    By te5la in forum C++ Programming
    Replies: 4
    Last Post: 07-23-2008, 05:37 PM
  3. Array of class objects
    By GCNDoug in forum C++ Programming
    Replies: 29
    Last Post: 03-26-2008, 04:30 PM
  4. Replies: 4
    Last Post: 10-16-2003, 11:26 AM
  5. base class pointer to derived class objects
    By curlious in forum C++ Programming
    Replies: 4
    Last Post: 09-28-2003, 08:39 PM