M
Mark Paskin
Hello, I'm having difficulty getting template matching to work with
inner classes. I've tried to look up the way to fix this in my
references, but I haven't found the fix yet. When I try to compile the
program below (g++ 3.3/4.0), I get
test.cpp: In function `int main()':
test.cpp:19: error: no match for 'operator<<' in 'std::cout << x'
Does anyone know what I'm doing wrong? Thanks!
Mark
#include <iostream>
template <typename T>
struct outer {
struct inner {
T z;
};
};
template <typename T>
std:stream& operator<<(std:stream& out,
typename outer<T>::inner& i) {
out << i;
return out;
}
int main(void) {
outer<int>::inner x;
std::cout << x;
return EXIT_SUCCESS;
}
inner classes. I've tried to look up the way to fix this in my
references, but I haven't found the fix yet. When I try to compile the
program below (g++ 3.3/4.0), I get
test.cpp: In function `int main()':
test.cpp:19: error: no match for 'operator<<' in 'std::cout << x'
Does anyone know what I'm doing wrong? Thanks!
Mark
#include <iostream>
template <typename T>
struct outer {
struct inner {
T z;
};
};
template <typename T>
std:stream& operator<<(std:stream& out,
typename outer<T>::inner& i) {
out << i;
return out;
}
int main(void) {
outer<int>::inner x;
std::cout << x;
return EXIT_SUCCESS;
}