Welcome to the VirtuQ Forums.
Results 1 to 2 of 2
  1. #1

    Difference b/w classes and structures

    Sir,

    Is the only difference b/w classes and structures is that by default the members of structures are public and of classes are private.?
    Can we declare members of a structure private, that is can a program written with classes also written with structures with same functionality?

    thanks,
    anon10125

  2. #2
    VirtuQ Moderator
    Join Date
    Jun 2011
    Location
    Bangalore, India
    Posts
    310
    Blog Entries
    4
    Hello Anon10125,

    Difference between struct and class is same as what you wrote. However, standard practice is to use class with proper public/private etc. and use struct in a manner similar to C struct.

    You can declare a member private inside struct in the same manner as you do inside class.

    -- Basant


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •