When is a static data member defined?
From: Steven T. Hatton (susudata_at_setidava.kushan.aa)
Date: 10/20/04
- Next message: Jay Nabonne: "Re: C++ IS OLD TEHNOLOGY!"
- Previous message: Default User: "Re: Windows App - C++"
- Next in thread: Victor Bazarov: "Re: When is a static data member defined?"
- Reply: Victor Bazarov: "Re: When is a static data member defined?"
- Reply: Ioannis Vranos: "Re: When is a static data member defined?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 20 Oct 2004 12:51:56 -0400
In the following code, at what point is S::c fully defined?
#include <iostream>
using std::cout;
using std::endl;
using std::ostream;
class C {
int _v;
public:
C(const int& v)
:_v(v)
{}
ostream& print(ostream& out) const
{
return out << _v;
}
};
struct S {
static const C c;
};
const C S::c = C(42);
ostream& operator<<(ostream& out, const S& s)
{
s.c.print(out);
return out;
}
int main()
{
S s;
cout << s << endl;
return 0;
}
-- "If our hypothesis is about anything and not about some one or more particular things, then our deductions constitute mathematics. Thus mathematics may be defined as the subject in which we never know what we are talking about, nor whether what we are saying is true." - Bertrand Russell
- Next message: Jay Nabonne: "Re: C++ IS OLD TEHNOLOGY!"
- Previous message: Default User: "Re: Windows App - C++"
- Next in thread: Victor Bazarov: "Re: When is a static data member defined?"
- Reply: Victor Bazarov: "Re: When is a static data member defined?"
- Reply: Ioannis Vranos: "Re: When is a static data member defined?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|