← Back to Question List
C++ Quiz #124
Defining get() Outside the Class Template
get() is declared inside Box but will be defined outside the class body, where the comment is. Which definition is correct?
📄 Code
1#include <iostream>23template <typename T>4class Box {5 T value;6public:7 Box(T v) : value(v) {}8 T get() const;9};1011// the definition of get() goes here1213int main() {14 Box<int> b(42);15 std::cout << b.get() << "\n";16 return 0;17}