Thread: error: request for member of non-aggregate type

  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,268
    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, 01:17 AM
  2. Little Array Difficulty
    By G4B3 in forum C Programming
    Replies: 16
    Last Post: 03-19-2008, 12:59 AM
  3. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  4. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 12:22 PM
  5. Replies: 0
    Last Post: 04-29-2003, 09:23 PM