Well, I think I am stuck:
Can somebody explain why Foo<12>(); outputs 5 and not - as I expected - 12?Code:template<int TSIZE> struct A { int get_size() const { return TSIZE; }; char buffer[TSIZE]; }; template<int TSIZE> void Foo() { char buffer[TSIZE]; std::cout << TSIZE << std::endl; } int main(int argc, char* argv[]) { A<12> a12; std::cout << a12.get_size() << std::endl; // outputs 12, ok A<5> a5; std::cout << a5.get_size() << std::endl; // outputs 5, ok Foo<12>(); // outputs 5, WHY??? Foo<5>(); // outputs 5, ok return 0; }




Reply With Quote