Question 9
Back to Exercise
For template<class T> struct Box { static inline int n = 0; };, do Box<int>::n and Box<char>::n refer to the same variable?
- A Yes
- B No – each instantiation is a distinct class with its own static members Correct
- C Only if both are used
- D It does not compile
Correct Answer: Option B
That is why CRTP bases can provide a separate counter per derived class.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!