class that will hold a collection of elements

say for example i got this code

Foo<string> f1;

What is the structure of foo?
is it like a normal declaration of class?

1
2
3
class Foo{

}


Or is it something else?
In your example Foo is an template class. It might look like that:
1
2
3
4
5
template <typename T>
class Foo
{
    T member;
};


When you instantiate it with concrete type, like Foo<string>, it will create a class where all entries of T will be replaced with that type. So deep inside the compler it would create class like:

1
2
3
4
class Foo@string /*name mangling so Foo<string> and Foo<int> would be different classes*/
{
    string member;
};
Topic archived. No new replies allowed.