Nested classes question...

This is a discussion on Nested classes question... within the C++ Programming forums, part of the General Programming Boards category; hi guys... i have a class called Astar and a Node class within it...i have a method readfile() outside the ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    124

    Exclamation Nested classes question...

    hi guys...

    i have a class called Astar and a Node class within it...i have a method readfile() outside the Astar class...I want to now declare a vector of Nodes within readfile() but I get an error: E2451: Undefined symbol Node...i write:

    vector <Node *> VectorOfNodes

    what's the problem?

    Best Regards,

    Farooq

    Here is the structure of the code:

    I am giving the strcutre below...I've removed most of the things so it's easier to understand. The error is in the line: vector <Node *> CityNode; in the method: readfile()

    class Astar
    {
    public:

    class Node
    {
    public:

    int x;
    int y;

    }

    }AstarSearch;

    Then:

    void readFile()
    {
    vector <Node *> CityNode;
    .................
    .................
    }

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >vector <Node *> CityNode;
    You need to tell the compiler that Node is nested in Astar:
    Code:
    vector <Astar::Node *> CityNode;
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    124
    works!!! thanks a lot...was confused about this for 2 days...best forum ever!
    Last edited by alvifarooq; 09-18-2004 at 05:03 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-28-2006, 02:59 PM
  2. Question With Nested If's
    By jarvis in forum C Programming
    Replies: 7
    Last Post: 07-26-2006, 08:06 AM
  3. Simple Question about Classes
    By Loctan in forum C++ Programming
    Replies: 5
    Last Post: 06-26-2006, 02:40 AM
  4. A little question about classes
    By Newbeee in forum C++ Programming
    Replies: 9
    Last Post: 06-15-2006, 03:46 PM
  5. Newbie question about the Private type in classes
    By Ryeguy457 in forum C++ Programming
    Replies: 1
    Last Post: 09-07-2002, 10:17 PM

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