Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!mips!sjsca4!poffen From: poffen@sj.ate.slb.com (Russ Poffenberger) Newsgroups: comp.lang.c++ Subject: How to correctly initialize struct/class Message-ID: <1990Aug20.220157.24736@sj.ate.slb.com> Date: 20 Aug 90 22:01:57 GMT Reply-To: poffen@sj.ate.slb.com (Russ Poffenberger) Organization: Schlumberger Technologies, San Jose, CA. Lines: 44 Hi, Is there a way (simple) to do the following. I want to define a union, such that it can be either a float value, or a pointer. union both { float value; float *value; }; Now I want to define a structure (or class) like so that uses several instances of this union. struct data { union both one; union both two; union both three; union both four; union both five; }; Now what I need to do is to declare an instance of the struct, but initialize all of the fields. Any of the fields may be initialized to either a floating point constant, or the address of a floating variable. e.g. float f1; float f2; struct data d1 = (&f1,4.3,&f2,7.2,0.0) struct data d2 = (0.0,1.0,2.0,3.0,4.0) etc... How can I declare a constructor to do this? Is it even possible? Russ Poffenberger DOMAIN: poffen@sj.ate.slb.com Schlumberger Technologies UUCP: {uunet,decwrl,amdahl}!sjsca4!poffen 1601 Technology Drive CIS: 72401,276 San Jose, Ca. 95110 (408)437-5254