[prog] C++ strange linking behaviour

Wolfgang Petzold petzold at villa-chaos.de
Tue Nov 9 10:12:37 EST 2004


Am 11/08/2004 10:22 PM schrieb Kathryn Hogg:

> So when the compiler instiantiates "amazing_gizmo<int>" and sees the
> reference to "amazing_gizmo<int>::rock_my_world()", it has to know how to
> instantiate it.  In order to do that, the compiler needs to see the
> definition of amazing_gizmo<T>::rock_my_world().

The longer I think about it, the clearer it gets.


>> Is there something like a "C++ one-liner of the month"-thing going on
>> somewhere? Who said that /perl/ was the hard-to-read-language? OK, just
>> kidding. But I'm impressed, really.
> 
> If you look at the code closely, you'll see that its just a wrapper around
> the std::copy() method that I gave you first.  It's just a style thing but
> I like the flow of not breaking up a
>     cout << .... << .... << endl;
> statment to print out containers.

Yes, I indeed looked closely and saw the similarity. But your
explanation will help even more.

My programming are mostly "at home" projects, and I am coding them
in Perl or Python -- dependant on the mood I'm in. And I was just
getting used to the Python way of OO programming. I have to say,
even if I can read the C dereference operator * quite well, I
still always get confused when I see (or worse, have to use) the
address-of operator &. More exercise needed, I guess.

Wolfgang


More information about the Programming mailing list