(ref.doc)smeyers 300395

Next clamage 290395 Prev: clamage 270395 Up: Usenet

Newsgroups: comp.std.c++
From: [email protected] (Note:
 Scott Meyers.)
Subject: Re: Implicit constructors and destructors
Date: Thu, 30 Mar 1995 00:07:28 GMT

In article <[email protected]> [email protected] writes:
| inline Foo &my_object()
|     { static Foo my_object_really; return my_object_really; }

This is one of the worst things you can do.  Because Foo is inline, it has
internal linkage, and you'll get a different copy of the function in each
translation unit.  Within each such function will be a *different* Foo
object.  In general, never make functions containing statics inline.  If
you feel compelled to do it anyway, declare the inline function extern.
This should make it behave the way you want to, but different compilers do
different things with functions declared like that.

automatically generated by info2www version 1.2.2.8