It's an exercise from C++ Primer 5th Edition:
Exercise 16.27: For each labeled statement explain what, if any, instantiations happen. If a template is instantiated, explain why; if not, explain why not. P.677
template <typename T> class Stack { };
void f1(Stack<char>); // (a)
class Exercise {
Stack<double> &rsd; // (b)
Stack<int> si; // (c)
};
int main() {
Stack<char> *sc; // (d)
f1(*sc); // (e)
int iObj = sizeof(Stack< string >); // (f)
}
Below is what I tried:
(a) Stack<char>
is instantiated , but no member of it is instantiated.
(b) Stack<double>
is instantiated , but no member of it is instantiated.
(c) Stack<int>
and its default constructor are instantiated.
(d) (e) totally no idea...
(f) Stack< string >
is instantiated , but no member of it is instantiated.
Am I right? Can anyone tell me how this code is instantiated?