class question.

This is a discussion on class question. within the C++ Programming forums, part of the General Programming Boards category; Heya. I wrote a simple class using public and private. can someone explain a bit more about the private part? ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    65

    class question.

    Heya.

    I wrote a simple class using public and private.

    can someone explain a bit more about the private part?
    About data members, and why private exist.

    thx.

  2. #2
    Registered User
    Join Date
    Aug 2008
    Posts
    188

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    Private makes something inaccessible by the outside world. It allows information-hiding. It's one of the most important concepts in OOP. I won't try to explain it, because any half-decent book (or even Google) will explain it better than I can.

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    65
    Thx for the answers, maybe I can ask another question.

    a parentes that have nothing in them, just ().. why do I sometimes need them? when they are just empty, like getGameName();

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Every function call needs parentheses, to distinguish it from a variable. If the function doesn't take any parameters, then the parentheses will be empty.

  6. #6
    Registered User
    Join Date
    Oct 2008
    Posts
    65
    I dont fully understand, but I will read more, thx for the fast replies =)

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,031
    Because C says that if you do not use () on a function, you take its address, and C++ is backwards compatible.
    But basically because the standard says so. It's the syntax of C/C++.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 02:03 AM
  2. Replies: 8
    Last Post: 10-02-2005, 01:27 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. question about DLL's and class functions
    By btq in forum Windows Programming
    Replies: 2
    Last Post: 02-25-2003, 06:08 AM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 07:51 PM

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