Results 1 to 5 of 5

Thread: How does a class vary from Structures ?

  1. #1
    Join Date
    Dec 2010
    Posts
    48

    How does a class vary from Structures ?

    Hello my friends I am a student of a college and right now started to do a bit of programming , by now I have learned few basic things, I have learned a bit fundamental concepts about classes and objects, bit when I started to study about the structures it almost look similar to me, I will appreciate if anyone could reply to my post.

  2. #2
    Join Date
    May 2009
    Posts
    511

    Re: How does a class vary from Structures ?

    The structure also called as struct default access modifier kind is public. A struct must normally be used for grouping data. and the modifier of the class is always private, and the form for inheritance is private. A class must be used for grouping data and functions that work on that data. In short, the principle is to utilize struct when the intention is to cluster data, and utilize classes when we need data abstraction and, maybe inheritance.

  3. #3
    Join Date
    Apr 2009
    Posts
    488

    Re: How does a class vary from Structures ?

    Normally structures and classes are alike. In truth, you can utilize structures in almost precisely the same method that you utilize classes. The only proper variation between a class and a structure is that in a class the members are not visible to everyone but in a structure they are public ally accessible by default. I do not think that structure allows static members, but it is allowed by the class.

  4. #4
    Join Date
    May 2009
    Posts
    529

    Re: How does a class vary from Structures ?

    Here is an example of both class and structure, the basic form of structure is similar to a class, as the class us defined with a ‘class’ keyword , similarly a structure is created using a ‘struct’ keyword
    class example
    Code:
    { 
      private: 
          int a; 
    
      public: 
          void function name() 
          { 
            // the code of a class  
          } 
    }; 
    
    
    
    struct example 
    { 
      private: 
          int b; 
    
      public: 
          void funname() 
          { 
            // code for a structure
          } 
    };

  5. #5
    Join Date
    Apr 2009
    Posts
    569

    Re: How does a class vary from Structures ?

    The above both code represents structures and classes each , this seems the most basic example the class is more widely used than a struct. Although in standard we can utilize a structure at every position whereas a class is used, in the majority of circumstances developers favor to make use of structures to cluster data, and classes to group both data and methods.

Similar Threads

  1. Advantages and disadvantages of OU structures
    By MrQ89 in forum Active Directory
    Replies: 1
    Last Post: 06-03-2012, 03:31 AM
  2. Cityville: Visiting neighbors is quite vary
    By Reema Roy in forum Video Games
    Replies: 4
    Last Post: 02-02-2011, 10:22 AM
  3. Conditional structures for VBScript
    By Kohlmann in forum Software Development
    Replies: 3
    Last Post: 30-11-2010, 01:05 AM
  4. How to use an Alternative Syntax for Control Structures in PHP?
    By - Empty Shell - in forum Software Development
    Replies: 5
    Last Post: 06-03-2010, 06:33 AM
  5. Pointer to an array of structures
    By Zool in forum Software Development
    Replies: 3
    Last Post: 13-05-2009, 10:51 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,727,049,973.93649 seconds with 17 queries