delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/06/12:03:12

Newsgroups: comp.os.msdos.djgpp
From: Peter Berdeklis <peter AT atmosp DOT physics DOT utoronto DOT ca>
Subject: Re: Problem with fstreams...
Message-ID: <Pine.SGI.3.91.970906095511.29094A-100000@atmosp.physics.utoronto.ca>
Nntp-Posting-Host: chinook.physics.utoronto.ca
Sender: news AT info DOT physics DOT utoronto DOT ca (System Administrator)
Mime-Version: 1.0
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: <Pine DOT SGI DOT 3 DOT 93 DOT 970829111108 DOT 28565A-100000 AT gibson> <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

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019