HDTenEightyP/NetNews huggingface dataset:
From: mat@mole-end
Subject: Re: The "has-a" relation in C++ ? How ?
Keywords: object,C++,has-a
Organization: :
Date: Tue, 21 Jul 1992 13:22:02 GMT

In article <1992Jul20.212525.5081@dsg.tandem.com>, narayan@aravali.everest.tandem.com (Pankaj Narayan) writes:
> Books typically go over the "is-a" relationship in much detail, saying how
> C++ has this great inheritance mechanism to support this sort of a
> relationship.
 
> However, when it comes to the "has-a" relationship, they don't really talk
> about or give implementation examples of how that is done in C++.  The
> Coad/Yourdon OOD book talks a little about it, and says that it can be done
> in a couple of ways, but does not give any substantial example.
 
> If you know of a book that does have a good example or description of this,
> please e-mail me your comments.  

You do it the same way you do it in C: by members that represent the
subsidiary objects, or by members that point to the other objects--in
other words, you are back in the world of data structures.  The
Structured Analysis/Structured Design people have made a very thorough
study of the topic and any book that covers Data Modelling/Information
Modelling should tell you all you ever wanted to know.

When I teach OO, I treat Inheritance as something `other than' a
Relationship; it avoids confusion between the two things that seem to
be of a different kind.  Inheritance is a relationship between two or
more kinds of category into which a thing falls; other relationships
are between two or more things (which occasionally may happen to be
the same).  I've gotten great results by identifying Inheritance before
I even start to _talk_ about Relationships; doing it in other ways led
to students coming up with many wierd interpretations for Inheritance and
many wierd class/relationship diagrams reflecting those interpretations.
When I had them identify the likely Inheritance hierarchies in the problem
before we even started to talk about relationships, they came up with
workable class/relationship diagrams for the problem in a few minutes and
generally on the first try.
-- 
 (This man's opinions are his own.)
 From mole-end				Mark Terribile

 uunet!mole-end!mat, Somewhere in Matawan, NJ
From: maxtal@extro.ucc.su.OZ.AU
Newsgroups: comp.lang.c++
Date: 18 Jul 92 10:37 MDT
Subject: Re: Speed, Correctness, Availabilit
Nf-ID: #R:1992Jun30.143631.13335@wsl.ie:1361663706:1992Jul18.063746.585@ucc.su.oz.a:1987128889:001:721
Nf-From: extro.ucc.su.OZ.AU!maxtal    Jul 18 10:37:00 1992


In article <23209@alice.att.com> ark@alice.UUCP () writes:
>at one of the previous two meetings.  Similarly, an individual not
>representing a company must have attended one of the previous two meetings
>in order to vote at the present one.  That makes it possible to skip
>the overseas meetings without losing the vote at the others.

	I live in Australia.

	ALL the meetings are 'overseas'. :-)

>-- 
>				--Andrew Koenig
>				  ark@europa.att.com


-- 
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------

Newsgroups: comp.lang.c++
From: mat@uunet.uu.net!mole-end
Subject: Re: virtual madness - problem with virtual base class
Summary: (B*)(void*) is NOT the same as (B*)
Organization: :
Date: Sun, 26 Jul 1992 02:54:47 GMT

In article <1992Jul24.190709.10315@walter.bellcore.com>, ik@snoopy.ctt.bellcore.com (Ik Su Yoo) writes:

>       void* bbp = &bb;
>       ((B*)bbp)->f();
>       ((A*)bbp)->f();

> Is this not a legal thing to do in C++? I thought I was allowed to cast to
> void* and back. I also tried the above code with g++ and it also gave me
> segmentation fault.
 
> Any insight or solution to this problem is appreciated. Thanks.

Casting of pointers in C is pure `bitblt.'  In C++, it can imply conversion.
For this reason, if B and D are part of an inheritance structure, there is
a critical difference between

	(B*)
   and
	(B*)(void*)

One of the current side proposals surrounding RTTI would seperate bitblt
cast from conversion cast.
-- 
 (This man's opinions are his own.)
 From mole-end				Mark Terribile

 uunet!mole-end!mat, Somewhere in Matawan, NJ
Newsgroups: comp.lang.c++
From: jimad@microsoft.com (Jim Adcock)
Subject: Re: Having this=0, class-name: :main() and tasking in c++
Date: 28 Jul 92 20:43:29 GMT
Organization: Microsoft Corporation

In article <1992Jul27.050315.3154@sunb10.cs.uiuc.edu> pjl@sparc10.cs.uiuc.edu (Paul Lucas) writes:
>In <1DDA4ACFA5BF800C41@ursula.lucas.lu.se> KOSU_MATSB@ROUTH.KOSUFY.LU.SE writes:
>
>>Two (three) questions on C++:
>
>>Question #1:	Having a 0 "this" pointer. Standard?
>
>*****>	I don't know what you mean by "standard."

I think the question being asked is:

"Is it strictly legal to invoke a member function via a null pointer"

????

IE

	Foo* pfoo = 0;
....
	pfoo->doSomething();

I believe the answer is "NO it is NOT strictly legal, rather if you do this
your results will be undefined."

ARM page 53 states:

"A postix expression followed by an arrow (->) followed by a 'name' is a
postfix expression.  The first expression must be a pointer to a class 
object and the 'name' must name a member of that class."

It is not completely clear whether "pointer to a class object" *really means*
"pointer to a class object"  or rather 
"expression of type 'pointer to class object' "

I take this to *really mean* "pointer to a class object"

Note, for example, if doSomething() is a virtual function, then a given
implementation might either cause a runtime error if "this" is null, 
or, if the implementation is "smart enough" to intuit the type of the
actual object [what actual object therefore what actual type?] then possible
the virtual dispatch would be optimized out.

Note also, for a data member, pfoo->member is clearly ill-defined if pfoo 
is null.

Also, note that in the presence of multiple inheritence, if the null
invoking ptr is to remain "null" within an invoked member function, then
at dispatch time there must be a null pointer test and fixup analogous
to the null pointer fixup on pointer assignment.  I don't believe compilers
currently commonly do this null pointer fixup when dispatching to virtual
functions -- nor would such a test and fixup on each dispatch be desirable.

Try the below example, and see if your compiler doesn't doesn't perform
this null-pointer fixup on dispatch.  If it does, then you'll get all
1's output.  If any none-1's are output, then your compiler doesn't
do the null pointer fixup on dispatch.

====================================

#include <iostream.h>

class A
{
public:
	double am;
	int isNull() { return !this; }
};

class B
{
public:
	double bm;
	int isNull() { return !this; }
};

class C : public A, public B
{
public:
	int isNull() { return !this; }
};

main()
{
	C* c = 0;

	cout << c->A::isNull() << '\n';
	cout << c->B::isNull() << '\n';
	cout << c->C::isNull() << '\n';
	return 0;
}
Newsgroups: comp.lang.c++
From: nikki@trmphrst.demon.co.uk (Nikki Locke)
Distribution: world
Subject: Re: Covariant Types in Derived Classes
X-Mailer: cppnews $Revision: 1.10 $
Organization: Trumphurst Ltd.
Date: Mon, 27 Jul 1992 20:55:45 +0000


In article <1MH5C0K@netmbx.netmbx.de> jrobie@netmbx.netmbx.de (Jonathan Robie) writes:

> nikki@trmphrst.demon.co.uk (Nikki Locke) writes:
> 
> >The report generator and the user interface tool does not _require_ RTTI. 
> >The objects to be displayed/reported on should return a Collection of field 
> >specifiers from a virtual function. These field specifiers can then be 
> >placed on a menu for user selection and placement. The field specifier 
> >will contain virtual functions to format, display, validate and set the 
> >value of each field. A generic user interface object can then be 
> >constructed to use these methods for displaying and/or editing the field.
> 
> Now for the key question: where does this Collection of field specifiers
> come from?  Are you implying that the *user* needs to code all this?  It
> should not be available to a general library class?
The user (by which I take it you mean programmer) would probably code this
by using predefined classes for such things as string and simple numeric
fields, and deriving from these classes where the field is complicated.

> 
> Why not allow default display using exactly the same information used by
> the debugger?
So, as I understand it, you want some kind of RTTI which enables you to 
determine not only the type (class) of any object, but also details of 
every public and private variable and implementation details within the 
class. Can this really be true ? If it is, you don't want C++ :-) I must 
be mis-interpreting, surely.

> The alternative is to require a programming strategy like this:
> 
> 	1.  Design the class you need
> 	2.  Write code to print objects of this class
> 	3.  Write code to store objects of this class in a database
> 	4.  Write code to display objects of this class
> 	5.  Write code to input and edit objects of this class
> 
> We all agree that reliable code is our goal.  General purpose tools
> which can largely automate steps 2-5 will greatly reduce the amount
> of code that needs to be written for each class.
Fine - but these general purpose tools should be code generators, not 
sufficient RTTI to enable any hack programmer to totally subvert the type 
system, encapsulation, data hiding and just about everything else that's 
good about OOPL's.
---
Nikki Locke              |                        | nikki@trmphrst.demon.co.uk
Trumphurst Ltd.          | Tel: +44 (0)691-670318 | nikki@cix.compulink.co.uk
PC and Unix consultancy  | Fax: +44 (0)691-670316 | nikki@kewill.co.uk
trmphrst.demon.co.uk is NOT connected with ANY other sites at demon.co.uk.
Demon.co.uk is a dial-up subscription access point to the Internet.
From: maxtal@extro.ucc.su.OZ.AU
Newsgroups: comp.lang.c++
Date: 17 Jul 92 19:28 MDT
Subject: Re: boolean (was: Re: typedef vs enum)
Nf-ID: #R:1992Jul11.195547.18323@cmcl2.nyu:1382747533:1992Jul17.152808.26721@ucc.su.oz:-1889889582:001:789
Nf-From: extro.ucc.su.OZ.AU!maxtal    Jul 17 19:28:00 1992


In article <5359@m1.cs.man.ac.uk> jk@cs.man.ac.uk (John Kewley) writes:
>What criteria would people wish for a boolean class?

	A bool is just like a bit.

	It can be promoted to any other arithmetic type, yielding
	the values 1 and 0.

	Arithmetic types convert to bool, yielding 1 if nonzero.

	Thats it.

	class bool {
		int x; // int can be anything compiler likes
	public:
		operator int()const{return x;}
		bool(const int y) : x(!!y){}
	};

	const bool true=1;
	const bool false=0;

	What doesn't this class do?
	
-- 
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------

Newsgroups: comp.lang.c++
From: dshaker@qualix.com (Doug Shaker)
Subject: Looking for testing s/w
Reply-To: dshaker@qualix.com
Organization: QUALiX Group, Inc.
Distribution: na
Date: Thu, 30 Jul 1992 20:42:25 GMT

I am looking for s/w designed to test C++ class libraries and
applications.  Any source - free, for money, or in development -
would be welcome.

 - Doug Shaker

	voice:	415/572-0200
	fax:	415/572-1300
	email:	dshaker@qualix.com
	mail:	Qualix Group
		1900 S. Norfolk St., #224
		San Mateo, CA 94403



Newsgroups: comp.lang.c++
From: jrobie@netmbx.netmbx.de (Jonathan Robie)
Subject: Re: Covariant Types in Derived Classes
Organization: netmbx, Berlin, Germany
Date: Mon, 27 Jul 1992 08:22:59 GMT

nikki@trmphrst.demon.co.uk (Nikki Locke) writes:

>> Not so.  A report generator might start by showing me the default
>> printout for an object.  I can grab fields with my mouse and move
>> them around or delete them.
>> 
>> A user interface tool might allow me to do something similar by providing
>> me with a default, editable window.
>> 
>The report generator and the user interface tool does not _require_ RTTI. 
>The objects to be displayed/reported on should return a Collection of field 
>specifiers from a virtual function. These field specifiers can then be 
>placed on a menu for user selection and placement. The field specifier 
>will contain virtual functions to format, display, validate and set the 
>value of each field. A generic user interface object can then be 
>constructed to use these methods for displaying and/or editing the field.

Now for the key question: where does this Collection of field specifiers
come from?  Are you implying that the *user* needs to code all this?  It
should not be available to a general library class?

Why not allow default display using exactly the same information used by
the debugger?

The alternative is to require a programming strategy like this:

	1.  Design the class you need
	2.  Write code to print objects of this class
	3.  Write code to store objects of this class in a database
	4.  Write code to display objects of this class
	5.  Write code to input and edit objects of this class

We all agree that reliable code is our goal.  General purpose tools
which can largely automate steps 2-5 will greatly reduce the amount
of code that needs to be written for each class.

It is just possible that some of this code contains errors.


Jonathan

===========================================================================

Jonathan Robie		jrobie@netmbx.UUCP
Arnold-Zweig-Str. 44	jrobie@netmbx.in-berlin.de
O-1100 Berlin		
Deutschland		Phone:  +37 (2) 472 04 19  (Home, East Berlin)
				+49 (30) 342 30 66 (Work, West Berlin)


-- 
Jonathan

===========================================================================

Newsgroups: comp.lang.c++
From: pjl@sparc3.cs.uiuc.edu (Paul Lucas)
Subject: Re: How to avoid calling destructor twice after fork()?
Organization: University of Illinois at Urbana-Champaign
Distribution: usa
Date: Wed, 29 Jul 1992 21:07:10 GMT

In <1992Jul29.180655.4716@cis.ohio-state.edu> gyu@cis.ohio-state.edu (george yu) writes:

>I am using fork() system call in my C++ program. The problem is that each
>calling of fork() creates a copy of calling process. The problem is any
>instances created and not destroyed before fork() calling will be 
>destroyed twice. The following figure shows the problem.

>class MY_CLASS;
>main()
>{	
>   MY_CLASS my_class;

>   if(fork()==0)
>    {
>       // process 1
>    }
>   else
>    {
>       // process 2
>    }
>   
>   // everything beyond this point will be executed twice, including
>   // the destructor of my_class.
>}

>Any suggestions?

*****>	fork() duplicates the entire process, data and all; so there
	are two copies of all objects created by new.  Call the
	destructor _once_per_process_ is what you want which is exactly
	what it does now.
-- 
	- Paul J. Lucas				University of Illinois	
	  AT&T Bell Laboratories		at Urbana-Champaign
	  Naperville, IL			pjl@cs.uiuc.edu
From: tom@fokus.gmd.de (Tom Pfeifer)
Newsgroups: comp.lang.c++
Subject: TurboVision Colors Question
Date: 31 Jul 92 11:02:58 GMT
Organization: GMD-FOKUS, Hardenbergplatz 2, 1000 Berlin 12, Germany

I use the color editor from the TVDEMO. Can anyone give me a hint how
I can save the result in a file? I tried to copy the palette with
 = getPalette() to a string, but this doesn't work.

Thanks Tom
Newsgroups: comp.lang.c++,comp.std.c++
From: smneyln@ariel.lerc.nasa.gov (Michael Neylon)
Subject: HELP with overloading binary operator...
News-Software: VAX/VMS VNEWS 1.41    
Organization: NASA Lewis Research Center
Date: 28 Jul 1992 10:11 EST  

I have the following class...

classs ARRAYBASE {
private: float matrix[MAXSIZE][MAXSIZE];
public: int xsize, ysize;
	ARRAYBASE(int x, int y) {xsize=x+1;ysize=y+!;};
// put + get handlers
// overloaded operator= which is fine
// Inverse() function, taken from _Num. Rec. in C_
	ARRAYBASE ARRAYBASE::operator*(ARRAYBASE array1, ARRAYBASE array2)
	{
		//fill the array using matrix multiplication
		//fill in matrix[][] and xsize, and ysize vars
		return *this;
	};
};

(obviously, this defines arrays with a base as 1 (a[1..6][1..6]))
However, when i compile, i get...
ARRAYBASE::operator*() must take only 0 or 1 arguments
huh? this is the same format that I can find in several C++ books for
overloaded binary operators.  Whats wrong?!

Mike Neylon          aka Masem the Great and Almighty Thermo GOD
  // Only the | Univ. of Toledo - Chemical Engineering - Senior
\X/   AMIGA!  |   NASA Lewis Research Center - Summer Intern
\_____________|_____smneyln@ariel.lerc.nasa.gov________________/
       -+ How do YOU spell 'potato'?  How about 'lousy'? +- 
      "Me and Spike are big Malcolm 10 supporters."-J.S.,PLCL
Newsgroups: comp.lang.c++
From: steve@taumet.com (Steve Clamage)
Subject: Re: strstream in BC++
Organization: TauMetric Corporation
Date: Wed, 29 Jul 1992 17:12:08 GMT

kevinl@tisdec.tis.tandy.com writes:


>	Does anyone know why istream extraction and ostream insertion
>operators (ie >> and << respectivly) are not overloaded for the strstream
>class in Borland C++?  It's not any problem to inherit them into a class
>that overloads them, and you can always to the strstreamobject.rdbuf()
>thing, but I don't think you should have to.  I'd appreciate a clue. 8-)

In the usual implementation, strstream is derived from iostream,
iostream is derived from istream and ostream, and the extraction
and insertion operators are in istream and ostream, respectively.
(Are you with me so far?)

Thus, strstream has the insertion and extraction operators by direct
inheritance, and you should be able to use them without any extra effort.

I don't have BC++ 3.0, but this was the case with earlier versions.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Vice Chair, ANSI C++ Committee, X3J16
Newsgroups: comp.lang.c++
From: ger@cv.ruu.nl (Ger Timmens)
Subject: NaN - magic value
Date: Wed, 29 Jul 1992 08:47:22 GMT
Organization: University of Utrecht, 3D Computer Vision Research Group

I want to assign a magic value to certain double variables;
Currently I return DBL_MAX, as defined in <float.h>.

Is it possible to assign the value NaN, to double variables ?
(NaN = NotANumber, e.g. dDouble = 1.0 / 0.0 ==> dDouble == NaN)

Thanks in advance,

-- 
Ger Timmens (ger@cv.ruu.nl) 3DCV Research Group, Utrecht, The Netherlands
Tel.: +31 -30 50 67 11;      Room: F.01.7.03;      Fax.: +31 -30 51 33 99
.....I'd rather hear Chet miss a note, than Wynton make a thousand......
Chet - Miles - Kenny - Lee - Arturo - Fats - Wynton - Art - Louis - Bix -
From: kenl@telxon.uucp (Ken K. Lambach)
Newsgroups: comp.lang.c++
Subject: Re: Protogen Code Generator
Date: 24 Jul 92 11:22:47 GMT
Reply-To: kenl@telxon.UUCP (Ken K. Lambach)
Organization: Telxon Corporation,  Akron OH

>
>I have PROTOGEN 2.0.
>
>The information on their ad is missleading.
>You have to read its ad very carefully. It reads(line 14 of the white half
>page ad):
>        ... preserves all of the code you add to this framework ...
>                                          ^^^	                
>But, I can not simply ADD code. The source code generated by it deos
>not give you any way to transfer data in/out dialog. You have to
>modify the source code. Your modification will be gone when you back
>to use it. I wrote a small C program to preserve my changes. But I
>have to add more and more features to my C tool to do what I want. So
>I gave up. I did not order 2.1 version when I ordered BC++ 3.1.
>
>If you want use it as a prototype generator, it works.
>
>I have to say: the name is not missleading: PROTOtype GENerator, not CODEGEN.

I also have PROTOGEN 2.0 (just got the 2.2 upgrade yesterday !).  I am a 
little confused by your comments.  Are you saying the code you enter in
your application is changed if you change your menus from Protogen ?

If you add your code only within the delimiters generated in the source
code by Protogen, your code will not change if you change the way the
menus work.  I have done this repeatedly without any loss of code.
When I was first learning to use Protogen, I mistakenly added some
code outside the delimiters and yes, I lost the code when I changed
the interface.  I then re-read the manual, and sure enough, it was
documented (sorry, I don't have my manual here to quote pages).

By the way, the upgrade to version 2.2 was only $5.00 with the
upgrade from BC++ 3.0 w/AF to BC++ 3.1 w/AF.  

Now if the OS/2 version of BC++ would be released :-).  Sorry about
that, no flames please.

Newsgroups: comp.lang.c++
From: mtsjej@gsusgi2.gsu.edu (slug)
Subject: beginner windows programmer quest...App Frameworks
Summary: how to code windows apps
Keywords: objectwindows,resource workshop,protogen
Organization: Georgia State University
Date: Fri, 31 Jul 1992 15:19:22 GMT


hi.....i am just about to start delving into the world of
Windows programming....i have a few questions though....i
have Borland C++ 3.1 with the App Frameworks and also Protogen 2.2.
what i am wondering is what people suggest as to writing
ObjectWindows Apps.....i assume i can go about in 3 ways:


  1. write all ObjectWindows code
  2. use Resource Workshop, ObjectWindows code
  3. use Resource Workshop, Protogen, ObjectWindows code


i am almost positive i will use the Resource Workshop but
am not sure about Protogen....i do have experience with C++
and also TurboVision......any comments...thanks in advance!!!


                                            -- jeff

Newsgroups: comp.lang.c++
From: leying@alpha (Leying Zhao)
Subject: Re: Protogen Code Generator
Organization: Faculty of Management, McGill University, Canada
Date: Wed, 22 Jul 1992 22:06:15 GMT

In article <2386@bsu-cs.bsu.edu> twpunix@bsu-cs.bsu.edu (Tim Parsons) writes:
>
>  Having recently registered my Borland C++/AF 3.0, I got a call from a 
>Borland rep offering Protogen for $49.95 (regularly $495, she said).
>Does anyone know if it's worth getting, what it's particularly suited for?
>It'd have a money-back trial period, but I'd like to know if it's something
>to seriously look into, before I make even such a modest leap.  I've scanned
>back issues of PC Week, etc., but info is pretty sketchy.  Thanks.
>
>Tim Parsons (twpunix@bsu-cs.bsu.edu)

I have PROTOGEN 2.0.

The information on their ad is missleading.
You have to read its ad very carefully. It reads(line 14 of the white half
page ad):
        ... preserves all of the code you add to this framework ...
                                          ^^^	                
But, I can not simply ADD code. The source code generated by it deos
not give you any way to transfer data in/out dialog. You have to
modify the source code. Your modification will be gone when you back
to use it. I wrote a small C program to preserve my changes. But I
have to add more and more features to my C tool to do what I want. So
I gave up. I did not order 2.1 version when I ordered BC++ 3.1.

If you want use it as a prototype generator, it works.

I have to say: the name is not missleading: PROTOtype GENerator, not CODEGEN.
From: stefan@mpi-sb.mpg.de (Stefan Naeher)
Newsgroups: comp.lang.c++
Subject: template argument as base class
Date: 23 Jul 92 13:49:51 GMT
Reply-To: stefan@mpi-sb.mpg.de
Organization: Max-Planck Institut fuer Informatik


Does anyone know a workaround for the following problem.

The current cfront version (3.01) does not support the use
of formal type parameters as base classes for templates.
Example: 

template <class T> class XYZ : public T { };

cfront says
"sorry, not implemented: formal type parameter T used as base class of template"

A possible application is the implementation of data types with implementation 
parameters, e.g., dictionary<skiplist>, dictionary<red_black_tree>, ....

Any suggestions are appreciated.

Stefan N"aher.
Newsgroups: comp.lang.c++