Thread: Cant understand weired problem...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    > Student *sa[3];
    If you want an array, just type Student sa[3] and leave out the *
    I believe that's actually a pointer to an array of Students.
    And then you can use this:

    sa[0] = Student("James");
    sa[1] = Student("Jason");

    If you wanted an array on the heap, you need to declare a pointer to a Student and allocate with new[]

    Student *sa;
    sa = new Student[3];

    and now you can use array indices like in the first example.

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Try including Course.h after Student.h. That might do something, otherwise, I'd like to see what's in those libraries.
    Sent from my iPad®

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM