Class Or Struct?

This is a discussion on Class Or Struct? within the C++ Programming forums, part of the General Programming Boards category; Hi, I need a structure that holds just 3 variables. Which (Class or struct) has the smallest memory footprint or ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    45

    Class Or Struct?

    Hi,

    I need a structure that holds just 3 variables. Which (Class or struct) has the smallest memory footprint or are they both the same in size?


    Many Thanks
    -Alex

  2. #2
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    891
    same.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    45
    Ok thanks!

    -Alex

  4. #4
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    307
    Even you can try union
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  5. #5
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    while they do the same thing (aside from structs default access being public, while class private). I tend to use structs for more non-functional entity's like descriptors or smaller data types.

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by Joelito View Post
    Even you can try union
    a union won't hold three variables.

  7. #7
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424

    Wink

    Quote Originally Posted by robwhit View Post
    a union won't hold three variables.
    At least not at the same time
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10:03 PM
  2. const elements of struct / class not accessible?
    By talz13 in forum C# Programming
    Replies: 2
    Last Post: 03-24-2006, 04:05 PM
  3. Function validation.
    By Fhl in forum C Programming
    Replies: 10
    Last Post: 02-22-2006, 07:18 AM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 06:18 AM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM

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