tags:

views:

321

answers:

4
+9  Q: 

Reverse C++ lookup

I am a "C" programmer that knows just the tiniest bits of C++. I am having a look at some open source C++ code trying to understand some things that it is doing. I can work out most of it but sometimes there is syntax I don't recognise and I'd like to be able to "look up" the meaning of the syntax so I can read just enough to understand that bit of C++. But you can't just type a bunch of symbols into google - or whatever to find out the meaning in C++. Any suggestions of how I can do this in general?

The specific syntax I'm struggling with right now is the following:

void Blah<BOARD>::Generate(SgPoint p)

What is the significance of the <BOARD> in this context? What should I look up in order to understand it?

+8  A: 

Blah is most likely a templated class, Generate is a method from this class and this is most likely the first line of the method definition.

Edit: Oh and BOARD is the template parameter (can be type or integral value).

Let_Me_Be
`<sigh>` It's a _class template_. There's no template classes.
sbi
@sbi Your are right that it's not a template class. But that's not what I wrote.
Let_Me_Be
@Let_Me_Be: I'm sorry. In my defense I can say I'm correcting someone on this almost daily here. That's probably why my pattern matcher incorrectly pavloved on your answer...
sbi
+3  A: 

You run into C++ templates - very neat feature!

phadej
+14  A: 

void Blah<BOARD>::Generate(SgPoint p)

Generate is a member function of a class template Blah .

BOARD is the name of the parameter.

Your class Blah could be like this :

template <typename BOARD>
class Blah
{
   //...some code
   void Generate(SgPoint p);
   //...some more code
};
Prasoon Saurav
+6  A: 

This is the Generate method of the Blah class template specialized for template parameter BOARD.

In other words, what follows is the actual code that gets called when the Blah template is used to process an instance of class BOARD.

Other classes may get processed in a different way if separate specializations exist for them, or via the default non-specialized implementation of Generate, or not at all if there is no default and no specialization for them - in which case, an attempt to call that function will not compile.

There is a short introduction to the topic of template specialization here.

Steve Townsend
Note that `BOARD` might be a template parameter, too, if Mick omitted the `template< typename BOARD >`.
sbi