information revealing . . . ?

This is a discussion on information revealing . . . ? within the C++ Programming forums, part of the General Programming Boards category; hey all, let's say i'm coding, coding, coding, making good progress and all, and then realize a crucial data is, ...

  1. #1
    Registered User blight2c's Avatar
    Join Date
    Mar 2002
    Posts
    266

    information revealing . . . ?

    hey all, let's say i'm coding, coding, coding, making good progress and all, and then realize a crucial data is, and rightly so, private in another class. should i make it public, use a get function (won't that double overhead), or move around two hours worth of work. i've never had a set back this big before, what should i do?

  2. #2
    Señor Member
    Join Date
    Jan 2002
    Posts
    561
    I'd just make it public, but that's cuz I'm lazy!

  3. #3
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    Posts
    230
    IMHO, it really depends on the situation and what's going on. In some cases you might want to use inheritence. Others you would use a friend function. Others you would use composition. Etc... Etc..

    Give us a little snippet or some code to help us give you more advice.

  4. #4
    Registered User InFeStEd-ArCh0n's Avatar
    Join Date
    Apr 2002
    Posts
    63

    Post Your subject is very broad

    MSDN has documentation on the "friend" keyword. This is what I suggest that you use. Check it out, tell me what you think and if it applies to you. "The friend keyword allows a function or class to gain access to the private and protected members of a class..."

    http://msdn.microsoft.com/library/de...ref_friend.asp

    Sorry if it isn't much help.
    -Mike
    {InFeStEd-ArCh0n}

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    591
    On a very general basis I would say to use a public access method(getXXX) to access privat member variables.

  6. #6
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    I'm going to agree with Barjor. Go through a method to get the value. It's good practice to do and it'll help keep your code modular.
    If a tree falls in the forest, and no one is around to see it, do the other trees make fun of it?

  7. #7
    Registered User InFeStEd-ArCh0n's Avatar
    Join Date
    Apr 2002
    Posts
    63

    Thumbs up I agree as well

    I do agree also, I was just providing some options. I would not personally use the friend keyword myself.
    -Mike
    {InFeStEd-ArCh0n}

  8. #8
    Registered User blight2c's Avatar
    Join Date
    Mar 2002
    Posts
    266

    wow guys thanks a lot. this is the best response i've had in a while. i tried the get function and it seems to be working fine. i think next time i'll use a freind just for the practice. again thanks a lot.

  9. #9
    Registered User InFeStEd-ArCh0n's Avatar
    Join Date
    Apr 2002
    Posts
    63

    Arrow The greater good...

    You're lucky, I'd imagine some people still have unanswered questions after posting on this board. The primary reason for me coming here, my one question, was never answered. The most of a response I got was somebody telling me it was possible. So if you know the answer to something that you see somebody is asking, don't hesitate to write it. Do not think that it is easy and somebody else will post the answer so you do not have to. It wouldn't be a messageboard if no one tried to respond. This messageboard is like its own minicommunity and everyone is part of it. Each person is a vital organ in this community, and each person plays a part. Granted, more ask than answer, but even if a selfish person answered every 1 in a 1,000 questions asked it would be a relief of stress off of another programmer's back. This practice (programming) should not be competitive in the least. Progammers should feel like they are part of their own community where each individual helps another out, and knowing that this help is for the greater good of all programmers. That one programmer helping another may become a contageous epidemic, influencing a programmer to repeat this action and to bear no resentment toward the programming world. If this were so then the technological world would progress a little more rapidly, and this world may smile a bit more. But, alas, it shall not. And I shall try and dream no longer.

    Sorry, I did not mean to go off onto such a tangent. I was merely stating my feelings, but clearly I have gone too far.
    -Mike
    {InFeStEd-ArCh0n}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 06-01-2009, 08:54 PM
  2. Struct/parse returning wrong information
    By dontknowc in forum C Programming
    Replies: 5
    Last Post: 12-04-2007, 01:39 PM
  3. Assignment Help !! (Student information system)
    By ashb in forum C++ Programming
    Replies: 6
    Last Post: 03-12-2005, 05:32 AM
  4. Going out of scope
    By nickname_changed in forum C++ Programming
    Replies: 9
    Last Post: 10-12-2003, 07:27 PM
  5. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-21-2002, 12:35 AM

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