error: request for member of non-aggregate type

This is a discussion on error: request for member of non-aggregate type within the C++ Programming forums, part of the General Programming Boards category; I created a vector of gameobject pointers the created astroid that inherit from gobject and am trying to call the ...

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    450

    error: request for member of non-aggregate type

    I created a vector of gameobject pointers the created astroid that inherit from gobject and am trying to call the transform member function of the astroids but am getting an error
    Code:
    vector<GObject*> gameObjects(10);
    .
    .
    .
    gameObjects[0] = spaceShip;
       for (int i = 1; i<10; i++)
         gameObjects[i] = new Astroid();
    .
    .
    .
     for (int i = 1; i<10; i++)
         gameObjects[i].transform();
    spaceduel.cpp:33: error: `transform' is not a type
    spaceduel.cpp:33: error: request for member of non-aggregate type before '(' tok en
    What does this error mean GObject is pure virtual is that what non-aggregate object means or what?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    try this instead:
    gameObjects[i]->transform();

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    450
    doh thanks

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    For objects in a game, I'd recommend a list<> rather than a vector<>, to make insertions and removals faster.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 02:17 AM
  2. Little Array Difficulty
    By G4B3 in forum C Programming
    Replies: 16
    Last Post: 03-19-2008, 01:59 AM
  3. Replies: 28
    Last Post: 07-17-2006, 12:35 AM
  4. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 01:22 PM
  5. Replies: 0
    Last Post: 04-29-2003, 10:23 PM

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