CJCoding With Joseph
15free / daySign inCreate account
Back to Multiple Choice Quiz

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics

Two-Type Template Class Output

C++ quiz · Question 56
mediumTemplates

What is the output of this code?

#include <iostream>
#include <string>
using namespace std;

template <typename K, typename V>
class Entry {
public:
    K key;
    V value;
    Entry(K k, V v) : key(k), value(v) {}
    void print() {
        cout << key << ": " << value << "\n";
    }
};

int main() {
    Entry<string, int> e("score", 100);
    e.print();
}