Thread: class question.

  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

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    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,336
    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
    Location
    Inside my computer
    Posts
    24,654
    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, 01:03 AM
  2. Replies: 8
    Last Post: 10-02-2005, 12:27 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06: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, 06:51 PM