Re: Different classes instantiated from templates SHARE static members!!!
Re: Different classes instantiated from templates SHARE static members!!!
- Subject: Re: Different classes instantiated from templates SHARE static members!!!
- From: David A Rowland <email@hidden>
- Date: Fri, 5 Jan 2007 16:14:27 -0800
Title: Re: Different classes instantiated from templates
SHARE st
At 4:48 PM -0700 1/5/07, Scott Ribe wrote:
Holy Cow! Am I going to have to keep a
machine with CodeWarrior on it for
the next 10 years???
The following outputs "foo2 - foo2" instead of "foo1 -
foo2"!
template< typename T > class t { public: static const char *
foo; };
typedef t< char > c1;
template< typename T > const char * c1::foo =
"foo1";
typedef t< float > c2;
template< typename T > const char * c2::foo =
"foo2";
int main (int argc, char * const argv[]) {
c1 obj1; c2 obj2;
std::cout << obj1.foo << " - "
<< obj2.foo << std::endl << std::flush;
return 0;
}
"foo" is a static member. It can't be bound to any
object of that class. It should not be possible to write
obj1.foo
A proper reference uses the class name to qualify the static
member
c1::foo
Yet, when I write:
std::cout
<< c1::foo << "
- " << c2::foo <<
std::endl << std::flush;
I still see "foo2 - foo2" !
We are both missing something.
D
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden