Path: utzoo!news-server.csri.toronto.edu!rutgers!ucsd!pacbell.com!decwrl!infopiz!lupine!rfg From: rfg@NCD.COM (Ron Guilmette) Newsgroups: comp.lang.c++ Subject: Re: Static members of class type Message-ID: <4195@lupine.NCD.COM> Date: 2 Mar 91 20:18:56 GMT References: <10927@jarthur.Claremont.EDU> Distribution: usa Organization: Network Computing Devices, Inc., Mt. View, CA Lines: 35 In article <10927@jarthur.Claremont.EDU> dfoster@jarthur.Claremont.EDU (Derek R. Foster) writes: +How do I tell a C++ compiler to call the constructor of a static +member variable of class type? + +class A +{ + A(int x) {do something}; +}; + +class B +{ + B(int y) {do something else}; + static int membervariable; + static A memberclass; +} + +A B::memberclass(42); + +but TC++ says that I'm trying to declare memberclass() outside of its class +declaration (which is perfectly true! Why won't it let me?) + +... How do I tell a C++ compiler to call the constructor of a static +member variable of class type? Is this a bug in TC++? In a word, yes. The declaration: A B::memberclass(42); should be allowed. -- // Ron Guilmette - C++ Entomologist // Internet: rfg@ncd.com uucp: ...uunet!lupine!rfg // New motto: If it ain't broke, try using a bigger hammer.