passing a templated struct...

T

Toby

Hail and well met.

I am trying to pass a templated struct to another template. Ex:

template <class VertexType>
struct EdgeNode {
VertexType index;
int weight;
};

template <class VertexType>
struct VertexNode {
VertexType info;
UnsortedType<EdgeNode<VertexType>> edgeList;
};

is this not legal? I am getting an error along the lines of:

c:\documents and settings\toby\my
documents\cpp\assignment6\graphtypelinked.h(16) : error C2146: syntax
error : missing ',' before identifier 'edgeList'

among others.
 
J

Jay Nabonne

Hail and well met.

I am trying to pass a templated struct to another template. Ex:

template <class VertexType>
struct EdgeNode {
VertexType index;
int weight;
};

template <class VertexType>
struct VertexNode {
VertexType info;
UnsortedType<EdgeNode<VertexType>> edgeList;
Try:
UnsortedType said:
Note the extra space between the '>'s.

- Jay
 
T

Toby

Jay said:
Try:


Note the extra space between the '>'s.

- Jay

It worked! Interesting.... Well thank you very much! I don't understand
why that tiny whitespace made a difference though... ?
Thanks!

-Toby
 
J

Jay Nabonne

It worked! Interesting.... Well thank you very much! I don't understand
why that tiny whitespace made a difference though... ?
Thanks!

I believe it has to do with C++ using a "greedy" parser. Which means it
will see those consecutive '>'s as a single ">>" token instead of as two
separate '>' tokens.

- Jay
 
T

Toby

Jay said:
I believe it has to do with C++ using a "greedy" parser. Which means it
will see those consecutive '>'s as a single ">>" token instead of as two
separate '>' tokens.

- Jay
Makes sense. Thanks again! (and i really appreciate your speedy
assistance, as this assignment is due tomorrow morning ;-] )

-toby
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top