HDTenEightyP/NetNews huggingface dataset:
From: garyp@manutius.UUCP (Gary Powell)
Newsgroups: comp.lang.c++
Subject: Re: Reference vs. Pointer
Date: 21 Jan 93 17:37:18 GMT
Reply-To: garyp@manutius (Gary Powell)
Distribution: na
Organization: Aldus Corporation, Seattle WA


One other thing references do well is when you are overloading operators
and attempting you can give oject symantics while not putting objects on the
stack. ie:

class foo {
    public:
    friend foo &operator/(foo &lhs,foo &rhs);
    // rest of definition....
}

foo & operator/(foo &lhs, foo &rhs)
{
    foo result;

    // Do result = lhs/rhs;

    .
    .
    .
    return result;
}

Which allows you to write;

{ 
   foo a,b(inital value),c(initial value);

   a = b/c;

}

PS.
  Be sure and write the copy constructor, and overload the assignment operator
  too.
Gary Powell ------------+ Internet:     garyp@aldus.com
c/o Aldus Corporation   | uunet:        manutius!garyp@uunet.uu.net
411 1st Ave South       | uucp:         camco!manutius!garyp
Seattle, WA 98104  USA  | Voice:        (206) 622-5500
Newsgroups: gnu.g++,comp.lang.c++
From: klamer@mi.el.utwente.nl (Klamer Schutte)
Subject: Re: g++ vs Sun C++ 2.1
Keywords: g++, c++
Organization: University of Twente, BSC-El
Date: Sun, 24 Jan 1993 15:37:20 GMT

In <1993Jan22.154545.6314@roadnet.com> rgb@roadnet.ups.com (Rudy Bonefas) writes:

] 1.  How do I build shared libraries with g++? I tried the -shared switch but
]	     it tells me that it doesn't recognize that option.

-fpic and -fPIC should do what you want.

] 2.  Aside from the obvious financial benefits of g++, can any of you former
]	 Sun C++ users inform me of the benefits/drawbacks to switching to g++.

g++ does not give any 'Not implemented' messages. However, some things are not
implemented, and make g++ dump core :-(.

g++ has (some) template support.

The C++ library with Sun C++ is a shared lib. libg++ is not, and this results
in quite big files. For example, this program:

#include        <iostream.h>

main()
{
        cout << "Hello, world\n";

        return 0;
}

resulted in a 16K executable for Sun C++, and a 81K executable for g++.

] 3.  I understand that g++ supports templates.  Where exactly is the 
]	  documentation for how to create template classes?  The only temmplate
]	  implementation which I am familiar with is ODI's compiler. 

See ARM. g++ specific documentation does not exist.

--
Klamer Schutte			Tel: +31-53-892778	Fax: +31-53-340045
Faculty of electrical engineering -- University of Twente, The Netherlands
preferred: klamer@mi.el.utwente.nl     SMTP: klamer@utelmi01.el.utwente.nl
Xref: sparky comp.lang.c++:19743 comp.object:4992
From: schnee@sail.ncsl.nist.gov (Rick Schneeman)
Newsgroups: comp.lang.c++,comp.object
Subject: Re: HELP : Array of objects of diff classes ??
Date: 22 Jan 93 12:24:51 GMT
Followup-To: comp.lang.c++,comp.object
X-Newsreader: TIN [version 1.1 PL7]

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
which can be implemented in C++ in a variety of ways. In pre-2.0
systems I would do it using macro expansion and the C++ preprocessor. 
Below, I give a small example of macro expansion to iterate a list
of classes.... 

//
// TITLE:  GENERIC.H, My generic header file for macro expansion.
// NAME:   Richard Schneeman
// DATE:   December 11, 1990
//
//
// "generic.h", this is my generic.h file for doing the macro expansion
// that will allow a generic singly linked representation. This will
// support the multiple class instances of customer, suppliers, and
// invoices that are instantiated.
//
// Gslist, is a version of a generic singly linked list as defined in
// Bjarne Stroudstrup's book C++ (section 7.3.5). This gslist will be
// used to facilitate the STORABLE[T] phenomena that Eiffel allows to
// represent generics/polymorphism.
//

#include "slist.h"

#ifndef GENERICH
#include <generic.h>	// don't bring in generic.h more that once
#endif

#define gslist(type) name2(type, gslist)
#define gslist_iterator(type) name2(type, gslist_iterator)

#define gslistdeclare(type)			\
    class gslist(type) : slist			\
    {						\
        int insert(type a)			\
	{					\
	    return slist::insert(ent(a));	\
        }					\
	int append(type a)			\
	{					\
	    return slist::append(ent(a));	\
        }					\
	type get()				\
	{					\
	    return type(slist::get());		\
        }					\
	gslist(type)() {}			\
	gslist(type)(type a) : (ent (a)) {}	\
	~gslist(type)()				\
	{					\
	    clear();				\
        }					\
    }; //end generic class gslist		\
    class gslist_iterator(type) : slist_iterator\
    {						\
      gslist_iterator(type)(gslist(type) &s)	\
      : ((slist &) s) {}			\
      type operator()()				\
      return type(slist_iterator::operator()());\
    }; // end generic iterator class		\


=======================
Richard Schneeman, NIST
Building 225, MS-B266
Gaithersburg, MD 20899
rschneeman@nist.gov
=======================
From: rose@t524i5.telematik.informatik.uni-karlsruhe.de (Ortwin Rose)
Newsgroups: comp.lang.c++
Subject: Re: Result of delete operator applied to null pointer?
Date: 24 Jan 93 11:25:22
Organization: /usr/users/rose/.organization
NNTP-Posting-Host: t524i5.telematik.informatik.uni-karlsruhe.de
In-reply-to: T.D.G.Sandford@bradford.ac.uk's message of 22 Jan 93 14:56:54 GMT


You may apply the delete()-operator to a null pointer without any problems.

-- O. Rose
   University of Karlsruhe
   Institute of Telematics
Newsgroups: comp.lang.c++
From: rmartin@stripe.Rational.COM (Bob Martin)
Subject: Re: HELP with File I/O
Organization: Rational
Date: Tue, 26 Jan 1993 23:01:25 GMT

andras@well.sf.ca.us (Andrew Raskin) writes:


|arsen@mindvox.phantom.com (Arsen Pereymer) writes:

|>  Hi everyone... I am having some trouble with file I/O

Perhaps, but there is a critical flaw which may be your problem...

|>  #include<stdio.h> 
|>  #include<conio.h>
|>  #include<string.h> 
|>  #include<malloc.h> 
|>  #include<dos.h> 
|>  main() 
|>  char *line;
|>  FILE *in, *out, *read; int i=0;
|>          clrscr();
|>          in = fopen("c:\\autoexec.bat","r");
|>          out = fopen("\\autoexec.dat","wb");
|>          for(i = 0;i <= 1;i++) {
|>                  line = (char *) malloc(sizeof(line));
                                           ^^^^^^^^^^^^
=======================================================

This is not doing what you think it is.  What is sizeof(line)?  It is
the size of the variable line.  This variable is a char*, thus the
size is the size of a pointer.  Probably 4, perhaps as small as 2.
You are certainly going to be reading in more than 2 or 4 bytes, so it
may very well be that your are corrupting the heap.  If fprintf is
using the heap for its buffer, you could be corrupting the i/o buffer.
This may be why the file appears unreadable....

|>                  fscanf(in,"%s",line);
|>                  fprintf(out,"%s",&line);
|>                  free(line);  }
|>          fclose(in);
|>          fclose(out);  char *r;
|>          read = fopen("\\autoexec.dat","rb");
|>          fscanf(read,"%s",&r);
|>          printf("\nName : %s",r);
|>          fclose(read);
|>          getch();
|>          return 0;
|>

|>   Any suggestions? Thanks in advance....
|>



--
Robert Martin       | Design Consulting    | Training courses offered:
R. C. M. Consulting | rmartin@rational.com |  Object Oriented Analysis
2080 Cranbrook Rd.  | Tel: (708) 918-1004  |  Object Oriented Design
Green Oaks, Il 60048| Fax: (708) 918-1023  |  C++
From: nikki@trmphrst.demon.co.uk (Nikki Locke)
Newsgroups: comp.lang.c++
Subject: Re: Question of scope
Date: 27 Jan 93 11:09:59 GMT
Reply-To: nikki@trmphrst.demon.co.uk
Organization: Trumphurst Ltd.
X-Mailer: cppnews $Revision: 1.31 $

In article <schmidt.33@rz.uni-passau.de> schmidt@rz.uni-passau.de (SCHMIDT GUIDO) writes:
> In article <1993Jan22.184558.21397@porthos.cc.bellcore.com> chw@bellcore.com (Charlie Woloszynski,MRE 2J-278,8295228,,27143) writes:
> >A (novice) question about scope.
..
> >Anyway, does the following call the destructor just after returning
> >from the foo?
> > 
> >   foo(& Derived1());
> > 
> >Does it have any ugly portability problems? 
> 
> I've tried this in the following short program. It seems to work. At the end
> of main() there are two different ways stated to do this. I don't know which
> one is better. Any comments from others please.

This appears to be rather a novice answer to the novice question :-)

The fact that a particular program, compiled with a particular compiler, 
works is not a useful indication of whether the program is even correct,
let alone portable !

The original question relates to the lifetime of unnamed temporaries - 
when is the temporary Derived1 destroyed. Opinions about the lifetime of 
such a temporary vary widely - even the ANSI committee are wrestling with 
this problem.

Having read the ARM (s 12.2, pp 267-270), I figure the construct is safe, 
because the ARM states : "If a reference is bound to a temporary, the 
temporary must not be destroyed until the reference is. This destruction 
must take place before exit from the scope in which the temporary is 
created."

I figure the temporary can't be destroyed until return from foo. I could 
easily be wrong, though :-)

Note, also, that some compilers (cfront, for example) have bugs in this 
area - an interesting program was posted here some weeks ago which 
demonstrated that cfront didn't even correctly match constructor and 
destructor calls (i.e. objects were constructed, but never destroyed). I 
was pleased to observe that this is one area where DOS compilers were 
better than cfront - all 3 of the DOS compilers I use handled the program 
correctly.

-- 
Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
Newsgroups: comp.lang.c++
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c++
Subject: Re: References to functions?
Date: 27 Jan 93 19:34:48 GMT
Organization: negligable

In article <1993Jan26.162624.14112@fcom.cc.utah.edu> swillden@cs.weber.edu writes:
|KOCHER@nvdv.e-technik.uni-stuttgart.dbp.de (HARTMUT KOCHER) writes:
|: In <1993Jan25.182507.13761@fcom.cc.utah.edu> swillden@news.ccutah.edu writes:
|: > : Not exactly. Let's say I have a callback class which takes a pointer
|: > : to a function in its constructor. If I use a pointer, a 0-pointer may be
|: > : passed. If I use a reference instead, I can make sure, that the user
|: > : supplies a valid function.
|: > Not really.  Try:
|: > typedef int (callbackfunc)(int);
|: > extern void set_callback(callbackfunc&);
|: > void foo()
|: >     {
|: >     callbackfunc* callback = 0;
|: >     set_callback(*callback);
|: >     }
|: > : Hartmut Kocher
|: > Shawn Willden
|: > swillden@icarus.weber.edu
|: 
|: Sure, but it's always undefined to dereference a 0 pointer.
|
|Yes, it is undefined, not illegal.  A compiler could warn about it in
|this case, I suppose, but a quick experiment shows that g++ 2.3.3, and
|Cfront 3.0.1 accept the above code without complaint and there are
|many situations in which the compiler couldn't know.

The fact remains that you have to pull a convoluted trick to
get this result.  If you do things like that you deserve to 
have your machine seize up when the reference gets used...

|: With a reference you always clearly state, that you are 
|: expecting a valid object/function, etc.
|
|This is true, as long as you realize that you are only stating that
|you expect a valid object/function.  You are not forcing the the user
|to supply a valid argument, which was what I understood your intent to
|be.

And with a pointer it is frequently allowable (expected even) that
a NULL pointer is allowable under certain circumstances.  With a
reference you are making it clear that you should provide something
valid.

|: Therefore, it's the callers responsibility to make sure he's passing a valid
|: argument, whereas with pointers, the function implementor has to check for
|: 0 pointers, because these are allowed by the language.
|
|It's always the caller's responsibility to pass a valid argument.  I
|agree that passing a reference *should* make it clear to the user that
|he needs to pass a valid function.  If you intended the reference

Sometimes NULL *is* a valid argument.  A reference argumetn indicates
that it is not.  A pointer argument leaves the point unclear.

|parameter to be a reminder then I agree.  This is, however, a
|strictly stylistic thing, not an example of a need for function
|references.  Now, if we had a way to impose run-time checks on the
|validity of pointers that are dereferenced and cast to references...

I think the overall benefit makes this more than a stylistic thing.


		-Richard Hartman
		hartman@ulogic.COM

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
I am just a figment of your imagination...
			...what does that say about *your* mental health?
From: bright@nazgul.UUCP (Walter Bright)
Newsgroups: comp.lang.c++
Subject: Re: Enum - a question
Date: 24 Jan 93 05:36:33 GMT
Reply-To: bright@nazgul.UUCP (Walter Bright)
Organization: Zortech, Seattle

In article <1993Jan18.171942.23923@netcom.com> erc@netcom.com (Eric Smith) writes:
/I've noticed that Zortech 3.04 makes its enums global even when they
/are found inside classes, but it makes the enumerators local to the
/class.  I don't know why they made the enums global.  It could be just
/a bug, or maybe there is some subtle reason for it from their point of
/view.

This was to be compatible with the older pre-nested class C++ compilers.
The current 3.1 release has nested types in conformance with the ARM.
Newsgroups: comp.lang.c++
From: feist@hp1.erib.uni-hannover.de (Michael Feist)
Subject: C++ and FEM
Organization: IfSuERiB, Uni Hannover, Germany
Date: Tue, 26 Jan 1993 14:37:54 GMT

Is there anybody working on the implementation of Finite-Elemente-Problems
to C++. There was a short diskussion in this newsgroup an half year ago.

I'm working on creating classes for the description of FEM-Modells
for fluid dynamics.

If somebody is interested on an exchange of experiences about this, please contact me.
-- 
_______________________________________________________________________________
    Michael Feist	feist@hp1.erib.uni-hannover.dbp.de
Institut fuer Stroemungsmechanik und Elektronisches Rechnen im Bauwesen 
			Universitaet Hannover
_______________________________________________________________________________
From: BPHEINTZ@UCSVAX.UCS.UMASS.EDU (BRADLEY P HEINTZ)
Newsgroups: comp.lang.c++
Subject: Special C++ progs/libs
Date: 26 Jan 93 23:49:56 GMT
Organization: B. P. Heintz & Associates
NNTP-Posting-Host: phobos.ucs.umass.edu
X-News-Reader: VMS NEWS 1.24

Does anyone have any info whatsoever on programs or libraries in C++
dealing with:

Voice Recognition
Natural-language interfaces
Parsing
Machine Translation

Thanks ahead of time.

- Brad

*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*
I'm not into money.  I'm into freedom.

(413)546-5152
bpheintz@phobos.ucs.umass.edu
Newsgroups: comp.lang.c++,comp.sys.ibm.pc.misc
From: kkuehl@cbnewsg.cb.att.com (Kevin Kuehl)
Subject: Difference between Turbo C++ and Borland C++
Followup-To: comp.sys.ibm.pc.misc
Keywords: C++, IBM PC, Borland
Organization: AT&T
Date: Thu, 21 Jan 1993 17:52:38 GMT


Could someone please explain to me the difference between Turbo C++ and
Borland C++?  I see there is about a $200 price difference and wonder
what I get for the extra $200.  Also, do you thing the extra $200 is worth
is for non-production programming?  I will be using is mostly just to
write small programs to keep my skills sharp and try new things.

Thanks a bunch,
-- 

Kevin Kuehl			AT&T Bell Labs
kevin.r.kuehl@att.com		Indian Hill
att!ihlpm!kkuehl		Naperville, IL
Newsgroups: comp.lang.c++
From: kessel@eos.arc.nasa.gov (Karen Kessel)
Subject: AI apps in C++ - a book
Summary: Looking for book on C++ AI applications
Keywords: book AI C++
Organization: NASA Ames Research Center
Distribution: usa
Date: Fri, 22 Jan 1993 21:11:20 GMT

Hi, I'm looking for a book that you might recommend that
gives lots of examples of using C++ in various AI types
of problems, anything from production systems to OOPs
and the like.

Also, I'd like the text to conform to the latest version
of ANSI C++.  Know of anything?

Thanks beforehand,
Karen Kessel
kessel@eos.arc.nasa.gov

Newsgroups: comp.lang.c++
From: dave@dhcs.demon.co.uk (Dave Hodgkinson)
Subject: Re: Optimized C++ library
Organization: IISC
	<1993Jan22.091616.29891@ncrcae.ColumbiaSC.NCR.COM>
Apparently-To: mail2news@news.demon.co.uk
Date: Mon, 25 Jan 1993 14:19:17 +0000


In article <1993Jan22.091616.29891@ncrcae.ColumbiaSC.NCR.COM> mahesh@elcaro1.ColumbiaSC.NCR.COM (Mahesh Zambani) writes:

   In article <1jofijINNm8o@rs2.hrz.th-darmstadt.de>, schrod@iti.informatik.th-darmstadt.de (Joachim Schrod) writes:
   |> In article <1jng9aINN39s@male.EBay.Sun.COM>, pauln@loopkill.EBay.Sun.COM (Paul Nguyen) writes:
   |> > 
   |> > 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.
   |> > 
   |> > Is it possible that compiling with -O uncovered a bug?
   |> 
   |> Yes, in the compiler. Might be that you use the CC of Sun? (0.5 :-)
   |> 
   |> --
   |> Joachim

	   I had the same problem on HP9000/700 and SCO V3.2. But I discovered 
   that only few source files were problematic. By compiling these without
   -O flag and compiling rest of the files with optimization, my application
   ( quite a big size ) worked correctly.
	   Off course, this depends on how many man hours you are ready to spend
   to save a few cpu (micro)seconds!! :-)

There are often caveats to optimisation use buried deep in the manual.
Sun, HP, MS and borland have all got such notes in my experience. You
should try to isolate the faulty code; you will probably find that the
compiler is making invalid assumtions in moving code out of loops or
somesuch.

Dave

--
Dave Hodgkinson | Nearest thing to a Chief Wizard at IISC | +44 71 628 6960
S:10 I:17 W:8 D:14 C:13 Ch: 15      About to die: daveh@cix.compulink.co.uk
            Direct, to my desk, three times a day ... dave@dhcs.demon.co.uk
   This message brought to you by the most excellent Demon Internet Service
Newsgroups: comp.lang.c++
From: steve@taumet.com (Steve Clamage)
Subject: Re: setjmp/longjmp question
Organization: TauMetric Corporation
Date: Tue, 26 Jan 1993 18:20:29 GMT

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.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
From: gerard@nova.stanford.edu (Gerard Yeh)
Newsgroups: comp.lang.c++
Subject: HELP: hardware description using C++
Date: 23 Jan 1993 00:02:23 GMT
Organization: Stanford University
Distribution: world
NNTP-Posting-Host: nova1.stanford.edu
Keywords: hardware, help

Hi  there,

I am new to the C++ programming language.  I am trying to model 
some hypothetical hardware using the C++ language.   I have spent
some time considering how one would implement a hardware behaviorial
model using the C++.  I have some ideas, but . . .

I  am wondering if anyone out there has attempted to do something similar.
I would appreciate any help pointer to examples, pit falls, even any existing
class definition you may like to share.   I would like to start a dialog with those
interested.  Please reply to me via email.
-- 
------------------------------------------------
Gerard K. Yeh                            ,__o
gerard@nova.stanford.edu            -  _-\_<,
Department of Electrical Engineering  (*)/'(*)
Stanford University
From: matt@centerline.com (Matt Landau)
Newsgroups: comp.lang.c++
Subject: Re: C++ develpment environments
Date: 21 Jan 1993 20:07:55 GMT
Organization: CenterLine Software, Inc.
NNTP-Posting-Host: 140.239.1.32

> Various threads about prices for Unix development tools being higher 
> than prices for PC development tools.

This is a copy of a posting I made in another newsgroup on this very
topic.  It seemed germane to the discussion here as well.  Although 
I work for CenterLine Software, one of the companies being discussed,
it should be understood that these are my opinions, and mine alone.

:: Fowarded from comp.sys.sun.misc
:: Subject: Re: Solaris 2 vs Windows NT: Sun is losing the desktop on price

In <1993Jan20.151816.4156@asd.com> scott@asd.com (Scott Barman) writes:
>It's more than just Sun (although they are a culprit, too).  For example,
>XVT, the folks who give you an API that will allegedly write programs
>for X OpenLook, X Motif, Windows, OS/2, etc. has a product for SCO Unix,
>which is X and Motif, for a price far less than their X/Motif product
>for the Sun.  I fail to see why these products would be drastically
>different and cannot see the justification in the pricing changes.  

It's all about size of the target market.  

If there are 10 million machines out there that can run your software, 
and your software is so great that you expect to capture 10% of the 
potential market (no mean feat in most cases), then you can afford to 
sell it for $100 and still make $100 million.

If there are 100,000 machines out there that can run your software, and 
your software is so great that you expect to capture 10% of the market
(still no mean feat in most cases), then selling for $100 will get you 
only $1 million, which may not even be enough to pay your development 
costs, vulture capitalists, etc.

>It's more than Sun, the entire industry has to wake up to this fact.  If
>they don't we will be living the computing vision of Billy Gates.  Now
>that's scary!

When the number of workstations in the field becomes large enough that 
the target popuplation of workstation users is as large as the target 
popuplation of PC users, then it will be economically feasible to sell
workstation software for the same price as PC software.  

Unfortunately, we're not there yet, and for most companies with serious 
development costs, it's not practical to offer $99 software.  There are
a few exceptions, but these are usually either small companies with very
low overhead and expenses, or large companies that subsidize their Unix
workstation software devleopment costs with income from their PC software
sales.  Medium sized companies without high-volume PC product lines are
caught in the middle.
--
 Matt Landau			Waiting for a flash of enlightenment
 matt@centerline.com			  in all this blood and thunder