Noob Questions...

This is a discussion on Noob Questions... within the C++ Programming forums, part of the General Programming Boards category; Hi. I'm learning C++ on my own (not able to take a class) and have a few noob questions that ...

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    1

    Noob Questions...

    Hi. I'm learning C++ on my own (not able to take a class) and have a few noob questions that could stand clearing up.

    1) I have alot of books to read so I can get the same point in different wording (helps me learn). On the sections with array's, I see statements like "int array[10]" for one. Then I was reading a older book and they used "vector". I know vector, you can increase the size of your array. The question is, in todays programming, which is preferred?

    2) I'm starting to get a grip on classes. I have seen and worked thru the usual examples (ie. Dog class). A class defines an object. But what then? Can someone give me a example of a practical use for a class. The dog example really doesn't do it for me. I guess i'm trying to understand the use of a class (not how to use it).

    Thanks for the help. I'm sure there will be more stupid questions in the future, but i'm kind of hung up on this one right now.

  2. #2
    C / C++
    Join Date
    Jan 2006
    Location
    The Netherlands
    Posts
    312
    1) Mostly vectors are preferred, but sometimes you will need arrays.

    2) In games, by example, an RPG game, you have the class called 'player' or something with all the data on that person (health, weapon, armor, inventory, exp, lvl, etc...). In that class you can add a constructor and a destructor (the constructor for initializing data to default)
    Operating Systems:
    - Ubuntu 9.04
    - XP

    Compiler: gcc

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    >> The question is, in todays programming, which is preferred?
    In C++, vector is preferred, although it is more of a replacement for dynamic arrays than small local ones like int array[10].

    >> Can someone give me a example of a practical use for a class.
    A vector is a practical use of a class. It encapsulates all of the details of an array into a (relatively) easy to use interface that hides some of the more dangerous details and takes care of the little things for you.

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,799
    Quote Originally Posted by Firemagic
    2) I'm starting to get a grip on classes. I have seen and worked thru the usual examples (ie. Dog class). A class defines an object. But what then? Can someone give me a example of a practical use for a class. The dog example really doesn't do it for me. I guess i'm trying to understand the use of a class (not how to use it).
    A very similar question was asked a couple weeks ago here.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  5. #5
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    Oh yeah...you can thank me for that one.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Few more noob questions
    By SlpCtrl in forum C Programming
    Replies: 12
    Last Post: 10-14-2008, 04:32 PM
  2. A bunch of REALLY uber noob questions
    By mcmasterballer in forum C Programming
    Replies: 1
    Last Post: 05-02-2008, 01:43 PM
  3. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  4. 2 very noob questions
    By chasingxsuns in forum C Programming
    Replies: 20
    Last Post: 05-07-2006, 11:04 PM
  5. just started using CPP, couple of arb NooB questions
    By sempuritoza in forum C++ Programming
    Replies: 1
    Last Post: 01-25-2005, 04:21 AM

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