Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5978453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:31:06+00:00 2026-05-22T21:31:06+00:00

I am looking into working code from Game AI by example book and there

  • 0

I am looking into working code from Game AI by example book and there is a part I do not understand.

There is

template <class node_type, class edge_type>   
class SparseGraph                                 
{ ... };

and

int SparseGraph<node_type, edge_type>::AddNode(node_type node)
{
  if (node.Index() < (int)m_Nodes.size())
...
}    

How can be node.Index()called?

There also is class

class GraphNode
{  
public:
...   
  int  Index()const{return m_iIndex;}
....
};   

and graph is created with this class

typedef SparseGraph<GraphNode, GraphEdge> NavGraph;
NavGraph * m_pGraph;

so I understand what node.Index() does, BUT
how can I call node.Index() while there is no guarantee that node_type is GraphNode.

what if node_type is not GraphNode??

Hope you understand my question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:31:06+00:00Added an answer on May 22, 2026 at 9:31 pm

    If node_type is not GraphNode, then your compiler will smack you and throw an error. However, if your class depends on the Index function, then you should document it as a requirement and any replacement for GraphNode must provide it, probably with some expected semantics.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for good/working/simple to use PHP code for parsing raw email into parts.
Hi and thanks for looking into this. I have a code I've been working
I am looking into internationalizing a Flex application I am working on and I
I'm working with someone who's looking to get back into programming after several years
Looking into selector performance between $('#ID1, #ID2, #ID3') vs $('1X CLASS'). Which is faster?
I am working on a little pinball-game project for a hobby and am looking
Currently working on re-writing several interfaces and looking at what options there are for
I am working on a game engine which is loosely descended from Quake 2,
I'm looking for some insight into the workings of Silverlight - at this time
By looking into the Open JPA website i've found that i can log the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.