Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How does a class vary from Structures ?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 30-12-2010
Member
 
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.

Reply With Quote
  #2  
Old 30-12-2010
Member
 
Join Date: May 2009
Posts: 503
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.
Reply With Quote
  #3  
Old 30-12-2010
Member
 
Join Date: Apr 2009
Posts: 484
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.
Reply With Quote
  #4  
Old 30-12-2010
Member
 
Join Date: May 2009
Posts: 525
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
      } 
};
Reply With Quote
  #5  
Old 30-12-2010
Member
 
Join Date: Apr 2009
Posts: 567
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 04:10 AM.