Re: [Dev-C++] Off:Classes Access Restrictions
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: B. <ama...@uo...> - 2002-10-29 17:41:15
|
Yes, perfect both methods and the solutions suggested. Thank you. The cla= ss side, that is, when the access to the fuction members of the class is made, it is we= ll defined. Now I'm thinking in a way to discover whose program is accessing them (th= e classes). In a Unix world I could check the gid and discover which kind of user pro= gram is requesting it. And in a Win environment? Are you understanding now? How can, in a run-time mode, I can check this = access Regards Andr=E9 =3D=3D=3D Daniel Glenfield wrote: > I'd considered derived classes as a solution, but I think perhaps the > exercise (it sounds like one) involves creating a portable class - one = that > can be plugged in to a project. > > The variables specified could have been anything, so we're not sure on > whether our solutions are going to work or not. The functions are not > specified so they could do anyhting. I thought setting access via the > constructors would work better. After all, if the object was to derive = the > class into child classes the exercise would have said so surely? > > >From: "Abhijit Shylanath" <mu...@gm...> > >To: "Daniel Glenfield" > ><sp...@ho...>,<ama...@uo...>,<dev...@li...= rceforge.net> > >Subject: Re: [Dev-C++] Off:Classes Access Restrictions > >Date: Tue, 29 Oct 2002 18:26:02 +0530 > > > >Greets, everyone. > > > > > So a superdummy could be (DummyAccess =3D true, NerdAccess =3D true= ) > > > and the function will not care what the object is named, it will ju= st > >see > > > the value of the variable for NerdAccess. If it were a string, the > >function > > > would have to be rewritten to accomodate "superdummy" > > > >I came in late (I'd disabled my mail delivery for sometime), so I may = not > >be > >talking about what you're talking about. But according to what Daniel = is > >talking about, someone wants a class, some parts of which are accessib= le to > >some dudes, other parts to other dudes. His method makes sense. Also, = it > >should be more efficient than using strings (less time to compare or > >check). > >You could also modify the method to use a flag, like > > > > Constructor(int access_mode); > > > >which could be a combination of > > > > #define FOO_MODE_DUMMY 0x01 > > #define FOO_MODE_NERD 0x02 > > > >like so: > > > > Constructor(FOO_MODE_DUMMY | FOO_MODE_NERD); > > > >Within the methods, checking would be like so: > > > > if(access_mode & FOO_MODE_NERD) > > { > > // Do nerdy stuff > > } > > > >But this method is run-time checking, and you wouldn't know what to do= if a > >dummy tries to access a nerd-only-function. Error-message? Drop to OS? > >Wouldn't it be better if there were compile-time errors? Yes, so we ha= ve > >the > >new and improved C++-style DERIVED CLASSES! Yes, with one simple wave = of > >the > >hand... never mind... how's this? > > > >class FooParent > >{ > > public: > > FooParent(); > > ~FooParent(); > > > > virtual int WhichFoo() =3D 0; > > > > private: > > int num_stuff; > >}; > > > >class FooDummy : public FooParent > >{ > > /* blah */ > >}; > > > >class FooNerd : public FooNerd > >{ > > /* different blah */ > >}; > > > >Was this what was asked? > > > >___________________________________________________________ > > > >Abhijit Shylanath > > > >E-mail: mu...@gm... || ibr...@bi... > >Web-site: http://mudeth.tripod.com/ > > _________________________________________________________________ > Surf the Web without missing calls! Get MSN Broadband. > http://resourcecenter.msn.com/access/plans/freeactivation.asp |