Thread: Prevent member variable from being modified after construction

  1. #16
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Or the pronunciation of 'gif'.

    I love a good Strong Bad reference:
    http://homestarrunner.com/sbemail51.html

  2. #17
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Beam me up Scotty.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #18
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Well "gif" has a set pronucation setforth by the creators. As such there is no argument.

  4. #19
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    @OP: The way I've always understood it is, as the class is being constructed, everything in the ':' section of the class constructor is basically a list of the parameters to pass to each of the member variables' constructors as they in turn are being created. If you have a member variable which is an object of another class that doesn't have a default constructor, then you are required to specify parameters in the ':' block for that member; otherwise, the default constructor is used. The same goes for POD types: You can choose to provide a value for its 'constructor' (or initialization for POD types, maybe), or you can choose not to - but in the case of declaring a const variable, there is nowhere else in your program that you can give it a value, so it must be done in the ':' block via the constructor argument.

    @Hijackers: I just found it funny that we're talking about Greek philosophers talking about Geek arguments
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  5. #20
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Don't worry Prelude, we all know you're the smartest Geek around.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  6. #21
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    My goodness, Prelude... it's gonna take me a while to get used to that new avatar...

  7. #22
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Quote Originally Posted by sean_mackrory
    My goodness, Prelude... it's gonna take me a while to get used to that new avatar...
    Whoa! Now I'm confuzzled too.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  8. #23
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Seeing as how this thread has already been hijacked mercilessly..
    I see Prelude's avatar problems have finally been resolved
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  9. #24
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    What avatar problem?

  10. #25
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I see Prelude's avatar problems have finally been resolved
    Yes, I'm happy.

    >What avatar problem?
    I couldn't change my avatar.

    >it's gonna take me a while to get used to that new avatar...
    Just stare at it for a few minutes and the overwhelming cuteness will cause all of your worries to evaporate. Though it may hurt my credibility a bit.

    "Wow, this Prelude person sure seems to know a lot about C++."
    *Look at the avatar*
    "Whoa, neko kawaii! ^_^"
    *Look back at the post*
    "What was I just thinking? I can't remember."

    My best code is written with the delete key.

  11. #26
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    http://cboard.cprogramming.com/showt...326#post418326
    Last post, by Prelude.. and she's referring to some earlier post, but I don't feel like searching through 20 bazillion pages for it

    **EDIT**
    Hm, reminds me of that world domination thread somewhere...
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  12. #27
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Oh! I remember that! That was about the same time as that little RobC incident...

    edit: Prelude - there's an idea for your list of memorable moments on Cboard *wink* *wink*

  13. #28
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >there's an idea for your list of memorable moments on Cboard *wink* *wink*
    Bleh, I'd rather forget about that ordeal. You can record it in the annals for me.
    My best code is written with the delete key.

  14. #29
    yes, I'm registered!!! algi's Avatar
    Join Date
    Nov 2004
    Location
    Ipswich
    Posts
    161

    Red face

    use const

  15. #30
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Um algi thats already been mentioned and the thread has been properly hijacked. Please do not attempt to rerail

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  3. Outputting to a File Modified Text
    By alpha in forum C++ Programming
    Replies: 8
    Last Post: 11-24-2003, 08:39 PM
  4. Replies: 3
    Last Post: 10-10-2002, 07:34 AM
  5. Using 'if' with char arrays or string objects
    By c++_n00b in forum C++ Programming
    Replies: 36
    Last Post: 06-06-2002, 09:04 PM