HDTenEightyP/NetNews huggingface dataset:
From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
Newsgroups: comp.lang.c++,comp.object
Subject: Re: HELP : Array of objects of diff classes ??
Date: 27 Jan 93 14:30:40 GMT
Article-I.D.: ucc.1993Jan27.143040.17236
Organization: MAXTAL P/L C/- University Computing Centre, Sydney

In article <20665@durer.cme.nist.gov> schnee@sail.ncsl.nist.gov (Rick Schneeman) writes:
>John MAX Skaller (maxtal@extro.ucc.su.OZ.AU) wrote:
>: 
>: 	Use a discriminated union. Oh, C++ doesn't have one,
>: so emulate one with an idiom.  Below I use pointers for 
>: illustration, you can put copies of the actual objects in
>: if you like (just get rid of appropriate *'s)
>: 
>
>Well done example, I would add that this is termed a GENERIC

	A constrained generic: it differs from unconstrained generics
for which C++ has template support.

>which can be implemented in C++ in a variety of ways. 

	As usual :-)

-- 
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;------ SCIENTIFIC AND ENGINEERING SOFTWARE ---ph:  2 799 8223 --------
Newsgroups: comp.lang.c++
From: jabraham@acs.ucalgary.ca (John Abraham)
Subject: Re: Not alone with trouble with BC 3.0! Was: Trouble with BC 3.0
Date: Wed, 27 Jan 93 16:41:59 GMT
Organization: The University of Calgary, Alberta

In article <1993Jan20.022618.18191@borland.com> pete@borland.com (Pete Becker) writes:
>In article <schmidt.28@rz.uni-passau.de> schmidt@rz.uni-passau.de (SCHMIDT GUIDO) writes:
>>Hello!
>>
>>Recently I posted an article in which I discribed my troubles with BC 3.0.
>>When my project was becoming a bit more complex the compiler suddenly
>>skipped over a few lines of instruction and jumped somewhere by random
>>(I guess). I checked it several times, I didn't make any mistakes. 
>>(I had turned off any optimizations and of course I compiled the file 
>>before executing it - I'm not stupid)
I thought I had the same problem.  But then I found out that I
just wasn't *saving* my files before running the debugger.  This
was a bug in the Turbo C++ for windows environment - It checked
for dependencies and recompiled before invoking the debugger, but
it didn't save the source files to disk.  Since it was smart
enough to recompile I just ASSUMED it would save the files.  It
took me a few hours to figure out...

--
"Wow, it's like a 'Calvin and Hobbes' fantasy but without the
artistic look to it" - Scott Adams' (SCOTTADAMS@AOL.COM) character
"Dilbert" talking about Internet.
-- 
John E. Abraham, P.Eng.               ***** University of Calgary
jabraham@acs6.acs.ucalgary.ca          **** Department of Civil Engineering
Mathematical Modelling                  *** 2500 University Dr. N.W.
Computer Simulation                      ** Calgary, AB, T2N 1N4
Transportation and Land Use Interaction   * Canada
From: pauln@loopkill.EBay.Sun.COM (Paul Nguyen)
Newsgroups: comp.lang.c++
Subject: Optimized C++ library
Date: 22 Jan 1993 00:48:41 GMT
Organization: Sun Microsystems, Inc.
Distribution: world
Reply-To: pauln@loopkill.EBay.Sun.COM
NNTP-Posting-Host: loopkill.ebay.sun.com


We have an application that runs OK when all the libraries were compiled with the
-g option.  But when the libraries were re-compiled with -O for optimization.  The
application seems to crash randomly in one of the library.  The library that it
crashes in was entirely written in C++ with inheritance, etc...

Is it possible that compiling with -O uncovered a bug?



Thanks,
Paul


Newsgroups: comp.lang.c++
From: pjl@cs.uiuc.edu (Paul Lucas)
Subject: Re: operators
Keywords: operators,inheritance
Organization: University of Illinois at Urbana-Champaign
Date: Fri, 22 Jan 1993 11:45:59 GMT

In <1993Jan21.165621.16704@jussieu.fr> clerc@gla.ecoledoc.ibp.fr writes:


>Id like to express in C++ the fact that operators < <= >= can
>be defined using operators > and = (eg: a < b  is b > a)
>I would use a class MathObj (that would implement < <= >= using > and =)
>and derive my classes from it, redifining only the basic operators > and =

	I assume you meant: "in terms of operators > and =="
							  ^
>How can I WRITE that in C++ ? (no template solution please)

	Make < and == virtual in MathObj.
-- 
	- Paul J. Lucas
	  AT&T Bell Laboratories
	  Naperville, IL
From: rteasdal@polyslo.csc.calpoly.edu (Rusty)
Newsgroups: comp.lang.c++
Subject: Any recommendations for introductory books?
Date: 27 Jan 93 21:46:32 GMT
Organization: Cal Poly San Luis Obispo, CSc Department



	The subject line should say most of it, but here's a
bit more background, in any case:

	I have a good friend who's planning to do some C++ 
programming for an applications package intended to run under
OS/2 2.x PM. He's skilled in C but hasn't really gotten his feet
wet with C++ yet, and asked me if I knew of any smooth introductions
by any author which I could recommend.

	After a few minutes' thought, I had to confess that I
couldn't think of a single one - I've probably read eleven or twelve
C++ books, and disliked every single one. I'd not recommend any of
the lot for a beginner, not without some trepidation.

	Are there any helpful suggestions out there? (No, sorry, I
don't have time to write one myself; the fuzzy logic textbook comes
first :-) Emailed responses are fine, but feel free to broadband it
if you deem the response of sufficient general interest. Thanks!




-- 
||||||||   Russ Teasdale -- rteasdal@polyslo.CalPoly.EDU  --  (Rusty)  ||||||||
-------------------------------------------------------------------------------
"Gentlemen, if we do not succeed, then we run the risk of failure." - D. Quayle
Newsgroups: comp.lang.c++
From: mh@batman.imat.uni-kassel.de (Martin Hollender)
Subject: gdb for SUN C++ ?
Organization: Free University of Berlin, Germany
Date: Wed, 27 Jan 1993 07:30:44 GMT

I'm looking for a version of gdb which is able to debug code compiled with
SUN C++.
My gdb manual says:

   The C++ debugging facilities are jointly implemented by the GNU C++
compiler and GDB.  Therefore, to debug your C++ code effectively, you
must compile your C++ programs with the GNU C++ compiler, `g++'.

gdb is able to step through my SUN C++ programm, but there is a problem with
printing out the values of variables.

Thank you.
--
Martin Hollender         Man-Machine Systems Lab     University of Kassel
tel.  ++49-561-804-2701  email: mh@batman.imat.maschinenbau.uni-kassel.de
Newsgroups: comp.lang.c++
From: ronys@calisto (Rony Shapiro)
Subject: C++ and shared libraries on SunOS 4.1.2
Keywords: shared libraries, cfront, g++
Organization: Robcad Technologies ( 1980 ) Ltd, Israel
Date: Mon, 25 Jan 1993 15:04:56 GMT

Hello,

I'm investigating the possibility of making our C++ libraries into
shared objects.

Sun's documentation is not too clear on how to do this with C++ files.

For example, I understand that for efficiency, I should put all my
"exported initialized data" in a single file, and that this file
should be included both in the .so (compiled -pic) and in a static
archive library (compiled ???) named .sa.

What, in C++ as implemented on cfront 2.1 (and also on g++ 2.3.3) is
"exported initialized data" ? static objects? vtables? How does
patch/munch interact with all this?

If anyone has successfully created a shared C++ library, I'd
appreciate the benefit of his/her experience.

Please email, if requested, I'll post a summary.


-- 
		Rony Shapiro

	ronys%robcad@uunet.uu.net OR  uunet!robcad!ronys
Newsgroups: comp.lang.c++,comp.sys.sgi
From: richarm@a.cs.okstate.edu (MCINTYRE RICHARD D)
Subject: Re: operator<<() with template arguments
Organization: Oklahoma State University, Computer Science, Stillwater
Date: Fri, 22 Jan 93 19:53:45 GMT
Keywords: c++ templates

In article <larryj.727575410@westech> larryj@westech (Larry Jones) writes:
>I have written a template class with multiple template arguments:
>
>template <class T, size_t dimensions>
>class Foo {
>public:
>  // Stuff
>
>private:
>
>friend ostream& operator<< (ostream&, const Foo<T, dimensions>&);
>};				// Foo
>
>However, when I try to define the operator<<() as defined below:
>
>ostream& operator<< (ostream& anOstream,
>		     template <class T, size_t dimensions>
>		     const Foo<T, dimensions>& aVector)
>{
>  return anOstream;
>}
>
>my compiler (SGI CC v3.10), generates an error:
>
>"doit.C", line 36: error:  argument declaration syntax

Try something like ostream& operator<<( ostream& Ostream,
				const Foo<T, dimensions>& FooThing )
			{
			// do something.
			return Ostream;
			}

I'm not sure about your version of the compiler, but what I listed
is pretty standard.  When your instantiating a tempate object, or
listing parameters, I don't think you need the
	"template <class T, size_t dimensions>" stuff.
Consult your compiler documentation to be sure of the specific syntax
on your version.

Be sure that you modify the declaration appropriately also.

>Thanks!
>
>Larry Jones

Hope that helps.



-- 
Name :		    Dallas McIntyre
Occupation :	    Student - Still looking for a "real" job.
Favorite Far Side : Tarzan Introducing Himself to Jane.
Email Address :	    richarm@a.cs.okstate.edu
Newsgroups: comp.lang.c++
From: rowley@base.cs.ucla.edu (Michael T Rowley)
Subject: Inheriting from cooperating classes (was: HELP : Array of objects...)
Organization: UCLA, Computer Science Department
Date: 27 Jan 93 20:13:30 GMT

The discussion of mixed lists brought to mind an issue that I have
recently been struggling with.

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

>In article <mcampbel.727881449@eola.cs.ucf.edu> mcampbel@cs.ucf.edu (Mike Campbell ) writes:
>> 
>> I agree with your analysis of the problem re: subclasses, however, what if
>> you buy/purchase/steal classes from multiple vendors/coworkers/victims ?
>> They necessarily will not have a common base class.  (Or is this correctly
>> deemed "superclass?")

>So miltiply derive from the vendors class and from a common base class of 
>your own.

This works fine unless you have cooperating classes.  I came across
this problem in some parsing classes, but a more familiar example
would be a LIST class, which uses a LIST_ELEMENT class.  Assume these
classes are distributed without source, and that, for some reason, you
want to modify the LIST_ELEMENT class.

OO marketing says that if you want to create a class that is just an
extension of an existing library class, all you have to do is inherit
from it and make your extensions in the derived (child, sub) class.

Problem: other classes in the library (e.g. LIST) create instances of
LIST_ELEMENT.  They won't use your new derived class!

I believe this is a problem with any class that has instances created
by other library classes.

In the system I was working on, I had source to the library classes,
so I changed the class name of LIST_ELEMENT to LIBRARY_CLASS_ELEMENT,
then made a new class called LIST_ELEMENT which inherited from the
original version.  This way my modified class was used by the other
library classes.

If I didn't have the source, what could I have done?

I can think of two mechanism which could solve this problem:

1) Never use another class from within a class.  Use only constrained
generic parameters (parameterized types).  Thus a generic list class
would need to be declared LIST[LIST_ELEMENT,MEMBER_TYPE], or, if you
made a subclass LIST[NEW_LIST_ELEMENT,MEMBER_TYPE].  It's a little
less ugly if generic parameters could have defaults, as in Sather 1.0.

2) Allow for the creation of new _parent_ classes for existing
classes.  The new parent would include an explicit listing of children
(the children then don't have to declare the parent).  Thus the
extensions get inserted into the desired class.  Any member functions
that the new parent needs to use from its child can be declared as
deferred functions.  Unfortunately, this does not allow for redefining
functions from the library class, only adding new functions.

Any other ideas?

Michael Rowley
rowley@cs.ucla.edu
Newsgroups: comp.lang.c++
From: kanze@us-es.sel.de (James Kanze)
Subject: Re: setjmp/longjmp question
Organization: SEL
	<1993Jan26.182029.23023@taumet.com>
Date: 28 Jan 93 19:40:37

In article <1993Jan26.182029.23023@taumet.com> steve@taumet.com (Steve
Clamage) writes:

|> kanze@us-es.sel.de (James Kanze) writes:

|> >The C++ standards committee have said that they are adopting the C
|> >library more or less integrally, so I would suppose that this means
|> >setjmp/longjmp too.

|> Yes, but with a caution.  If the longjmp bypasses destruction of 
|> automatic objects, the results are undefined.

|> In other words, if you have C code which uses setjmp/longjmp and is
|> otherwise legal C++ code, it will still be legal C++ code.  If you
|> add creation of auto objects which have destructors between the
|> setjmp and the longjmp, the code no longer has defined semantics.
|> (This could happen by calling a C++ routine from the original C code,
|> for example.)

|> The idea is to use exceptions rather than setjmp/longjmp in new code.

I would love to, but my compiler doesn't agree.

Just so I don't get too bad of a reputation as a hacker (what, setjmp,
longjmp in C++), in the case I used it, I made very sure that the
functions being called didn't use *any* variables on the stack except
pointer variables.  All real objects (with constructors and
destructors) were allocated on the heap, and had a common base class
which registered them in a list.  When setjmp was called, everything
in the list was deleted.  Also, longjmp was never called from within
a constructor.

As a more general rule, you can emmulate exceptions with
setjmp/longjmp, if you accept that all of your class objects derive
from a common base class, which determines (in some machine dependent
fashion) whether the object is on the stack or not, and if it is,
registers it.  This is definitely non-trivial, though, and in the
presence of multiple inheritance, you'd better be sure that your
compiler does virtual base classes right, too.  (GNU definitely has
problems, and I have heard that Borland does too.)  Also, it has a
non-negligible run-time overhead.
--
James Kanze                             email: kanze@us-es.sel.de
GABI Software, Sarl., 8 rue du Faisan, F-67000 Strasbourg, France
Conseils en informatique industrielle --
                   -- Beratung in industrieller Datenverarbeitung
Newsgroups: comp.lang.c++
From: thg@hprnd.rose.hp.com (Terry Gong)
Subject: Help: USL Library Problem on SUN
Date: Thu, 28 Jan 1993 19:30:38 GMT
Organization: HP Roseville Networks Division
X-Newsreader: TIN [version 1.1.3 PL7]

I am trying to use the USL library on the Sun SparcStation 2
running SunOS 4.1.3.  I have the latest C++ compiler 3.0.1.
I am getting the following error:

"/usr/include/SC/List.c", line 351: error:  reference to const object
"/usr/include/SC/List.c", line 351:      error detected during the instantiation
 of Const_listiter <AddressFilterSpec>
 "Listiter__pt__20_17AddressFilterSpec.cc", line 8:      is the site of the inst
antiation
"/usr/include/SC/List.c", line 351: error: no standard conversion of const Addre
ssFilterSpec* to AddressFilterSpec&
"/usr/include/SC/List.c", line 351:      error detected during the instantiation
 of Const_listiter <AddressFilterSpec>
 "Listiter__pt__20_17AddressFilterSpec.cc", line 8:      is the site of the inst
antiation
"/usr/include/SC/List.c", line 372: error:  reference to const object
"/usr/include/SC/List.c", line 372:      error detected during the instantiation
 of Const_listiter <AddressFilterSpec>
From: maennig@siggi.informatik.uni-dortmund.de (Olaf Maennig)
Newsgroups: comp.lang.c++
Subject: How use new to create a 2-dimensional array
Date: 26 Jan 1993 15:45:45 GMT
Organization: CS Department, Dortmund University, Germany
Distribution: world
Reply-To: maennig@siggi.informatik.uni-dortmund.de
NNTP-Posting-Host: siggi.informatik.uni-dortmund.de

Hi, netters!

I'm a beginner in C++, so please no flames!

I haven't achieved to create a two-dimensional array via the new operator
yet. In fact, I want to have an array containing pointers to self-defined
structs (but that's not the point).

I tried:
	my_struct **var;
	...
	var = new (my_struct*)[number];

That doesn't work (why?).
Who can tell me what I'm doing wrong and how to make it right?

Thanx.
	Olaf
-- 
 ---------------------------------------------------------------------------
     _                   Department of Computer Science IV
    / \     |\/|         University of Dortmund, Germany
    \_/laf  |  |aennig   e-mail: maennig@siggi.informatik.uni-dortmund.de
         ------------------------------------------------------------
         "To unnderstand recursion you need to understand recursion."
 ---------------------------------------------------------------------------
From: linton@argosy.UUCP (Tom Linton)
Newsgroups: comp.lang.c++
Subject: Smalltalk -> C++
Date: 27 Jan 93 00:15:45 GMT
Reply-To: linton@maspar.com (Tom Linton)
Distribution: comp.lang.c++
Organization: MasPar Computer Corporation, Sunnyvale, CA


Does anyone know of a reliable program which can
convert Smalltalk to C++?

 
Newsgroups: comp.lang.c++
From: ik@puffin.ctt.bellcore.com (Ik Su Yoo )
Subject: virtual multi-method in C++?
Reply-To: Ik Su Yoo <ik@mobydick.leis.bellcore.com>
Organization: Bell Communications Research
Date: 27 Jan 93 08:59:49


This has been bugging me for a long time and I was wondering if this is
doable in C++. Here's the problem:

Say I have a hierarchy of data structures rooted at class D, something
like:
    
  class D {};
  class D1: public D {};
  class D2: public D {};

And I want to build an editor for manipulating the data structures.

Typically, the editor is sensitive to the type of the data that it is
manipulating. For example, there may be a constraint that says a D2
may be displayed inside a D1 but not vice versa. So, I (try to) express
this constraint using virtual functions:

  virtual int D::canContain(const D&) = 0;
  virtual int D1::canContain(const D2&) { return 1; };
  virtual int D2::canContain(const D1&) { return 0; };

But this does not work, since all these functions have different
signatures. So, I expand it to:

  virtual int D::canContain(const D1&) { return 0; };
  virtual int D::canContain(const D2&) { return 0; };
  virtual int D::canContain(const D1&) { return 0; };
  virtual int D::canContain(const D2&) { return 0; };

  virtual int D1::canContain(const D2&) { return 1; };

This is horrible, since D now has to be aware of all its derived classes.
The reason why I want to make canContain() virtual is because I want to
treat all objects uniformly as having type D*.

I'm pretty sure this could be cleanly handled if C++ provided a virtual
multi-method mechanism, but I don't think C++ does. Does anyone see a
better way of doing something like this in C++?
--

Ik Su Yoo
RRC-4F728, x5764
ik@mobydick.leis.bellcore.com
Xref: sparky comp.lang.c++:20025 comp.lang.c:20302
From: jerry@pawnee.telecom.ksu.edu (Jerry Anderson)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: Pointers to Functions
Date: 28 Jan 1993 08:55:05 -0600
Organization: Kansas State University
NNTP-Posting-Host: pawnee.telecom.ksu.edu

acctpu@vaxa.hofstra.edu writes:

> I was wondering.  If I define a pointer to a function

>     void (*fp)()

> How would I get the pointer to *point* to a function, and
> how would I *execute* the function the pointer is pointing
> to.

---------- cut here ----------
/*
 * Just an example of pointers to functions.
 */

#include <stdio.h>

void foo()
{
    printf("\nAha!  A successful call to foo()!\n\n");
}

main()
{
    void (*fp)();

    /*
     *  "How would I get the pointer to *point* to a function"?
     */
    fp = foo;

    /*
     *  "and how would I *execute* the function the pointer is
     *  pointing to"?
     */
    fp();
}

-- 
jerry@telecom.ksu.edu                     Jerry Anderson
                                          Kansas State University
vox: (913) 532-6936                            Telecommunications
fax: (913) 532-7114                       Manhattan  KS  66506
Xref: sparky comp.lang.c++:19892 comp.std.c++:2120
From: davidm@consilium.com (David S. Masterson)
Newsgroups: comp.lang.c++,comp.std.c++
Subject: Callbacks -- suggested approaches??
Date: 26 Jan 93 01:13:43 GMT
Organization: Consilium Inc., Mountain View, California
X-Posting-Software: GNUS 3.13  [ NNTP-based News Reader for GNU Emacs ]

I'm looking for suggestions on how to handle callback functions in C++ that
will be more standard than the one we're currently using.

Our application is a distributed system composed of many processes performing
specialized functions.  Each process is represented as a Process object with
specializations derived from this base.  Processes communicate by passing
Message objects that contains any necessary data.  The receiving Process
object looks into the incoming Message, determines its type (a number), and
dispatches it (via table lookup) to a callback function on the Process object
that has been previously registered for that type of Message.  The table where
messages are looked up is (basically) of the following definition:

	typedef	void	(Process::*Method)(Message*);
	struct Callback {
		Method		method
		Process*	methodthis;	// could be multi-threaded
	} table[MAXCALLBACKS];

Methods would be dispatched like:

	void Process::Dispatch(Message* m) {
		return (table[Lookup(m)].methodthis->*
			table[Lookup(m)].method)(m);
	}			

The registration method for callbacks looks like:

	void Process::Register(Method m, Process* p) {
		table[i].method = m;
		table[i].methodthis = p;
	}

and is called like:

	mainproc->Register((Method) MYProcess::callback1, myproc);

My problem that precipitated this posting was the Method cast in that last
statement.  Our applications could have potentially hundreds of callbacks in
any one process (especially the database interface), so keeping the callbacks
that a process could handle with the process seemed to be a win for
maintenance.  However, that last statement doesn't seem to be a legal one as
callback1 is not necessarily declared as a Method and the explicit cast is
overriding the warning that you would get.  Much of this design was done
originally with a C++ 2.0 compiler, but we are now moving to a C++ 2.1
compiler and trying to clean up the design in the process.  Is there a more
appropriate design for the above (that, hopefully, doesn't mean scrapping
everything)?  I've been looking at the idea of Functors, but that seems like a
maintenance nightmare in that there would be potentially hundreds of
single-function functors lying around in our system (a table lookup seems a
much more straightforward approach).

Any ideas?
--
====================================================================
David Masterson					Consilium, Inc.
(415) 691-6311					640 Clyde Ct.
davidm@consilium.com				Mtn. View, CA  94043
====================================================================
I try to stay away from liberalism.  I know how dangerous it is for
our... Don't ask me to take a liberal position where I am right now.
It's contrary to the administration's viewpoints.  It would not be
terribly helpful to anyone, especially me.
                -- Vice President Dan Quayle.
Newsgroups: comp.lang.c++