Thread: Array of objects

  1. #1
    Registered User
    Join Date
    Oct 2001

    Unhappy Array of objects

    "Create a 13 element array of Card objects".

    Tried typing: Card Hand[13];

    Wouldn't work tho. Card is my class, hand is the name of the object i'm trying to create. First time programming in nearly a year and my assignment is already 3 weeks late =(. Any help will be appreciated. Oh and if you need to see any other code to help, just ask, thx.

  2. #2
    It should work. Did you remember to include the header for your card class? Also did you make a default constructor for the card class? If you will recall when creating an array of objects teh default constructor is called automaticly.

    hope this helps

  3. #3
    Registered User
    Join Date
    Oct 2001
    Thanks alot, I did forget to include the class header. So when passing the object to functions its just "createNewHand(Hand[13]);"? My teacher wants main.cpp as just a driver of my program, code should be in a seperate file. So i'm declaring and calling my functions in main but i'm writing the code of the functions in a seperate file. Do I need to link main.cpp to bridge.cpp (where my functions are coded) just at compile time? Or do i need to include something at the top of the bridge.cpp function?

  4. #4
    Registered User
    Join Date
    Aug 2001
    each file you include with #include is a header file and should have a cpp or c or lib or dll file associated with it that will automatically be linked to the cpp file that has your main(). Only one cpp file per project should have a main().

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. question about multidimensional arrays
    By richdb in forum C Programming
    Replies: 22
    Last Post: 02-26-2006, 09:51 AM
  3. Replies: 4
    Last Post: 10-16-2003, 11:26 AM
  4. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  5. Adding objects to an array
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 11-27-2001, 09:24 AM