template instantiation rule.

Hi everyone

Consider the code snippet below..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Employee
{

};

template <typename T>
class EmployeeVector : private Employee
{

};

template <typename TP>
class EmployeeOrderedVector : private EmployeeVector<TP>
{

};

class Manager
{
};

int main()
{
EmployeeOrderedVector <EmployeeOrderedVector<Manager> > _managerList;
return 0;
}


I would like to know what all template classes would be instantiated when we create the _managerList object?

What is the rule here??

Regards
Rajat
I would guess, just the one class EmployeeOrderedVector<EmployeeOrderedVector<Manager> >.

It that class had members that were templates themselves, they'd be instantiated too, but you haven't shown any.
Since derivation is used, when EmployeeOrderedVector< foo > is instantiated, due to inheritance of EmployeeVector<TP>, part of EmployeeOrderedVector< foo >'s instantiation will include an instantiation of EmployeeVector< foo >, and so forth.

Since this is most likely a homework assignment, I'll leave it up to you to figure it out from there.
Topic archived. No new replies allowed.