Newsgroups: comp.os.msdos.djgpp From: Peter Berdeklis Subject: Re: Problem with fstreams... Message-ID: Nntp-Posting-Host: chinook.physics.utoronto.ca Sender: news AT info DOT physics DOT utoronto DOT ca (System Administrator) Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Organization: University of Toronto - Dept. of Physics In-Reply-To: <5uisve$sfg@freenet-news.carleton.ca> Date: Sat, 6 Sep 1997 14:16:28 GMT References: <5u62mh$9l6 AT freenet-news DOT carleton DOT ca> <34077a34 DOT 845806 AT snews DOT zippo DOT com> <5u8pmk$7j1 AT freenet-news DOT carleton DOT ca> <34087191 DOT 15417632 AT snews DOT zippo DOT com> <340B1EAB DOT 1F5BC046 AT alcyone DOT com> <5uisve$sfg AT freenet-news DOT carleton DOT ca> Lines: 41 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On 3 Sep 1997, Paul Derbyshire wrote: > How do the enum elements BINARY and so forth become members of ios, as in > ios::, and not of some enum? Normally the :: thing only applies to member > functions and instance variables, not to enums. Is the enum actually > inside the class? Can a class contain structs and subclasses actually > inside itself so they are only defined in the scope of the class, for > naming purposes? The enums in ios are defined within the class. As a result the enums only exist within the class' namespace and you have to use explicit scoping to use them, as in ios::bin. Note that binary is still a member of an enum, called open_mode. Any class, structure or enum contained inside another exists only inside the namespace of the surrounding class. Therefore, it is possible to do the following: struct outside { struct inside { struct way_inside { static int static_data; int data; } w_ins; } ins; } test_struct; To get access to the variables static_data and data you would use, resp.: outside::inside::way_inside::static_data = 1; test_struct.ins.w_ins = 1; To create instances of the inner classes you do the following: outside::inside test_ins; outside::inside::way_inside test_wins; --------------- Peter Berdeklis Dept. of Physics, Univ. of Toronto