Difference: Struct - Class

This is a discussion on Difference: Struct - Class within the C++ Programming forums, part of the General Programming Boards category; What is the difference between a Structure and a Class? Because they seem the same... Can you not place functions ...

  1. #1
    Unregistered
    Guest

    Question Difference: Struct - Class

    What is the difference between a Structure and a Class?

    Because they seem the same... Can you not place functions inside a Structure or something?

  2. #2
    Registered User Tazar's Avatar
    Join Date
    Aug 2001
    Posts
    13
    The main difference it that a class has a constructor and a destructor a strcture does not have them also you can put functions in a class and varables you also have the abilty to make some of the varables and functions private or public in the class. That's pretty much what I know about them I bet there are lots of people on this board that can tell you more ^_^ but I hope this helps anyways
    Tazar The Demon
    -------------------------------------
    Please check my site out at: http://www.lrs.8m.com thanks =)
    -------------------------------------
    Note:
    I will help newbies and any other person that I can just ask I'll try to help you out =)

    My MSN Messager name is: Tazar37@hotmail.com see if I'm online maybe we can talk. =)

  3. #3
    Unregistered
    Guest

    Smile

    Structrues and Classes are basically the same execept for the syntax and the fact:

    in classes
    variables and functions (not OOP speak!!) are private by default.
    That is why we have the keywords public and private in C++

    A class would resemble a structure if all variables and functions were declared as public.

    in structrues

    variables and functions are public by default.


    Hope this helps!!

  4. #4
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330
    In C++, structures and classes are the same, except structure's default data access level is public.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting from C to C++
    By Taka in forum C++ Programming
    Replies: 5
    Last Post: 04-08-2009, 03:16 AM
  2. Replies: 10
    Last Post: 05-19-2006, 12:23 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 02:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21