HDTenEightyP/NetNews huggingface dataset:
From: je@unix.brighton.ac.uk (John English)
Newsgroups: comp.lang.c++
Subject: Re: Help with nested class and constructor
Date: 20 Nov 92 15:45:12 GMT
Organization: University of Brighton, UK

macg9505@uxa.cso.uiuc.edu (Michael Alan Corn) writes:
: 
: I could use a little help on nested classes:
:       I would like to include one of Borlands Array classes in another class,
: in the private data section, but since the constructor requires an int to
: initialize the class, I'm not sure how or where to give it the value:
: 
: class foo {
:       private:
:       Array myarray(10); ///this doesn't work, the compiler chokes
              ^^^^^^^^^^^
	      This is a constructor call to Array, not allowed here.
That's why the compiler chokes.  What you need is:

     Array myarray;

in the class declaration, and in the constructor do this:

    foo::foo () : myarray (10) { } // Array constructor for myarray
				   // gets called at foo construct time.
-- 
-------------------------------------------------------------------------------
John English			| "Yes, understanding today's complex world of
Dept. of Computing		|  the future IS a little like having bees live
University of Brighton		|  in your head... but, there they are..."
Janet: je @ unix.brighton.ac.uk	| "People who live in windowed environments
Fax:   0273 642405		|  shouldn't cast pointers"
-------------------------------------------------------------------------------
Newsgroups: comp.lang.c++
From: mg@tyrolia (Michael Golan)
Subject: Re: Just what is so great about streams?
Organization: Princeton University, Dept. of Computer Science
Date: 17 Nov 92 03:00:38 GMT

Hi!

Any good reason why
  cout << fmt("%5d %5d\n") << x << y ;
or even
  cout("%5d,%5d\n") << x << y ;
do not exist?

  cout << dec(5) << x  << " " << dec(5) << y << "\n" ;

is not type-safer, is it? the formatting is ignored if x,y have non-int
type, just like %5d would be.

Obvious implementation
fmt saves the format string in the stream class and prints the 
text upto the first '%'. Then every << should call
pre_process_format() to extract the %X and set up the correct internal
parms, and post_process_format which continues the output of the fmt string.
Of course %*.*f can not be handled, but thats ok.

Also, the book fails to mention that cin.get(c) is slower than getchar()
by a factor of 2 or so. Same for fread vs. cin.read(), at least in the
simple timing I made under BC++3.0. This is a serious problem, e.g., when
you read a 32k chunks of bin data into memory. 

Michael

Newsgroups: comp.lang.c++
From: ssaksena@ccorp.uucp (Sandeep Saksena - asr1)
Subject: Concurrent C/C++
Organization: Citicorp, New York City
Date: Sun, 22 Nov 92 20:11:28 GMT

I am looking for an implementation of Concurrent C/C++ on a Sun sparc2. If
anyone has information on where I can obtain such a compiler, either as
public-domain or by purchase, I would appreciate it.

Thanks




-- 
Sandeep Saksena
ssaksena@citicorp.com
(212) 291-6007
From: 00skolis@leo.bsuvc.bsu.edu
Newsgroups: comp.lang.c++
Subject: Object Oriented Programming?
Date: 17 Nov 92 18:10:28 GMT
Organization: Ball State University, Muncie, In - Univ. Computing Svc's

I am currently doing research on the subject of Object Oriented Programming
for an Information Systems class.  I need to convey this concept to the
class in understandable, but specific terms. I would like to know what
specific items might be discussed with the group and what types of analogies
would help convey these ideas to a class that has only heard the term
Object Oriented Programming before.
Newsgroups: comp.lang.c++
From: news@sifon.cc.mcgill.ca
Newsgroups: comp.lang.c++
Subject: RE: Good C++ Magazine?
Date: 21 Nov 92 23:43:56 GMT
Organization: McGill University

In article <1992Nov21.212053.6413@kong.gsfc.nasa.gov> joslyn@kong.gsfc.nasa.gov (Cliff Joslyn) writes:
>I've been a loyal subscriber to the /C User's Journal/ for a while,
>but I'm moving into C++ completely, and honestly it's a bit behind me
>now. I enjoy the C++ column, but want a C++ only magazine. I got a C++
>Newsletter for a while, but it was really expensive.
>
>Is there anything out there?
>
>Thanks.
>
>O----------------------------------------------------------------------------->
>| Cliff Joslyn, Cybernetician at Large, 327 Spring St #2 Portland ME 04102 USA
>| Systems Science, SUNY Binghamton      NASA Goddard Space Flight Center
>| cjoslyn@bingsuns.cc.binghamton.edu    joslyn@kong.gsfc.nasa.gov
>V All the world is biscuit shaped. . .
>.
>.
Newsgroups: comp.lang.c++
From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
Subject: Re: The fate of my exponentiation operator proposal
Organization: MAXTAL P/L C/- University Computing Centre, Sydney
Date: Fri, 20 Nov 1992 13:19:32 GMT

In article <MATT.92Nov17132404@physics16.berkeley.edu> matt@physics.berkeley.edu writes:
>I believe that object-oriented programming is a genuine advance on
>previous methods, 
>
>So I am certainly willing to look at other languages than C++; it's
>foolish to become emotionally attached to any particular programming
>language.  At this point, however, I would prefer to look at languages
>which were designed for object-oriented programming.  And, obviously,
>I would also prefer languages which are widely available on a variety
>of platforms, and which have reasonably efficient implementations.
>These requirements narrow the field quite a bit.
>

	I suspect that it is not C++ OO features that will be most useful
to Fortran users but the ADT facilities (both are provided by the class
mechanism in C++, the ADT additionally has templates).

	I think it is a pity that the proposal was not accepted.

-- 
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
From: jim@galifrey (Jim Weirich)
Newsgroups: comp.lang.c++
Subject: Self Deletion
Date: 20 Nov 92 22:17:51 GMT
Organization: GE Corporate R&D Center
X-Newsreader: Tin 1.1 PL3

I am writing a windowed application using C++.  Each window is a C++
object and interprets button presses and such through member
functions.  When the CLOSE button is pushed, I wish to delete the
window. The most straight forward way is have the window object delete
itself by saying "delete this;" inside the member function handling
the CLOSE button. This seems to work, but I wonder if it is proper to
delete an object while executing one of its member functions.

Work arounds obviously are possible (e.g. mark the object for
deletion, then have another object actually do the "delete" sometime
later), but why complicate things if self deletion is "OK".

Any Comments? ... (E-Mail or Post)

-- Jim Weirich (jim@galifrey.ae.ge.com)
Newsgroups: comp.lang.c++
From: robert@slipknot.rain.com (Robert Reed)
Subject: Re: Good C++ Magazine?
Reply-To: robert@slipknot.rain.com.UUCP (Robert Reed)
Organization: Home Animation Ltd.
Date: Sun, 22 Nov 1992 23:36:59 GMT

In article <1992Nov21.212053.6413@kong.gsfc.nasa.gov> joslyn@kong.gsfc.nasa.gov (Cliff Joslyn) writes:
|I've been a loyal subscriber to the /C User's Journal/ for a while,
|but I'm moving into C++ completely, and honestly it's a bit behind me
|now. I enjoy the C++ column, but want a C++ only magazine. I got a C++
|Newsletter for a while, but it was really expensive.
|
|Is there anything out there?


C++ Report, one of the SIGS publications, is not bad.  It has a regular column
by Andrew Koenig (what OO magazine doesn't? ;+) and regularly deals with
everything from OO databases to design strategies, to a monthly summary of this
newsgroup.  It's $69 a year, from SIGS Publications, 588 Broadway, New York NY
10012.
________________________________________________________________________________
Robert Reed			Home Animation Ltd.		503-656-8414
robert@slipknot.rain.com	5686 First Court, West Linn, OR 97068

We offer the party as a big tent.  How we do that within the platform, the
preamble to the platform, or whatnot, that remains to be seen.  But that
message will have to be articulated with great clarity.
--Dan Quayle, interview with the Washington Post, December 1989
________________________________________________________________________________
Newsgroups: comp.lang.c++
From: sailors@CS.ColoState.EDU (robert sailors)
Subject: Re: New Employee Test
Date: Sat, 21 Nov 1992 19:34:15 GMT
Organization: Colorado State University, Computer Science Department

In article <1992Nov19.010534.19506@cs.yale.edu> rescorla@rtnmr.chem.yale.edu (Eric Rescorla) writes:
>In article <1992Nov19.002724.13837@en.ecn.purdue.edu> krauskop@en.ecn.purdue.edu (Curtis D Krauskopf) writes:
>>Suggestions that a quicksort or other algorithm be used (especially
>>since quicksort is a standard library function) get many bonus points.
>be heapsort, as far as I can tell. 
>
>Also, I'd note that you specified that the guy should create a bubble
>sort. One might believe that you had a specific reason why you wanted
>that. I certainly wouldn't tell someone who was writing code for me

So, the best bonus question might be, "Excuse me sir/Ma'am, do you have a
good reason to use the bubble sort?  I could maybe make a faster one, if you
want."
From: jbn@lulea.trab.se (Johan Bengtsson)
Newsgroups: comp.lang.c++
Subject: Re: question on REFERENCES
Date: 18 Nov 92 13:22:34 GMT
Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
X-Newsreader: Tin 1.1 PL4

swillden@news.ccutah.edu (Shawn Willden) writes:
: kestes@nswc-wo.nswc.navy.mil (Kent Estes) writes:
: : 
: : I am working on a function that references objects via id.  Upon finding
: : an object, it returns a reference to that object.  My question is :
: : if the object is not found, what is the best way to handle this.  If 
: : I were returning pointers to objects, all I would have to do is
: : return NULL.
: 
: So return a pointer.  There is no way to return a NULL reference (which
: is good, if you have a reference you *know* that it refers to something).
: 
: If there really is a good reason why you need to return a reference 
: instead of a pointer you can declare a special object of the return
: type that is always to be returned in case of error and then compare
: the address of the returned object with the address of the error 
: object (or overload operator== and play games with that).  Usually,
: though, you're better off just returning a pointer.

I disagree.  The described scheme requires the user to test
the result of every function call that may fail.  This is error prone,
and in the case of NULL pointers causes program termination (on
many machines), if overlooked.  Also, the code tends to be severely
cluttered with tests for NULL.

A better approach (IMHO) is to register errors in an error variable,
which can be a global variable, or one per object (for member functions).
The error variable must be explicitly read and reset, before proceeding.
The iostream library uses this approach, guaranteeing that all operations
on a stream are ignored until the error is fixed.  The advantage is
that it is OK to omit some error tests, several function calls may
safely be made before testing for errors.

Of course, true C++ exceptions is the superior alternative (:-).

-- 
--------------------------------------------------------------------------
| Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden  |
| Johan.Bengtsson@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490  |
--------------------------------------------------------------------------
From: andy@federation.gatech.edu (Andy Register)
Newsgroups: comp.lang.c++
Subject: Re: Can someone please help me with streams?
Date: 18 Nov 92 14:33:29 GMT
Organization: CERL-EE, Georgia Institue of Technology

In article <1992Nov18.033505.1617@lugb.latrobe.edu.au> ECSC9120802J@LUST.LATROBE.EDU.AU (GRANT,David) writes:
|>
|>I a new programmer to c++, and at the moment I am having trouble with streams.
|>I have overloaded the istream operator >>, to read in character by charater and
|>copy into an array. (It does a few other things as well.) The trouble I am
|>having is that I can't get it to recognise spaces or carrage returns. It just
|>seems to ignore them totally. I was wondering how I can get it to recognise
|>these characters, as it is inportant to my program. 
----------------------------------------------------------
Yep, istream ignores whitespace (blank, tab, newline, formfeed, cr).

Try cin.get() instead.  Stroustrup, The C++ programming language, 2nd
ed., pp. 330-333 has examples.

Toodles
Andy

Newsgroups: comp.lang.c++
From: nelsonc@colossus.cs.rpi.edu (Chris Nelson)
Subject: Re: Class design problem
Organization: Rensselaer Polytechnic Institute, Troy, NY
Date: Tue, 24 Nov 1992 02:43:21 GMT

Sorry, my reader failed me.  "Class design problem" should have started
a new thread.

                                  Chris


-- 
------------------------------+------------------------------------------
Chris Nelson                  |  Rens-se-LEER is a county.
Internet: nelsonc@cs.rpi.edu  |  RENS-se-ler is a city. 
CompuServe: 70441,3321        |  R-P-I is a school in Troy!
From: sjm@bcrki65.bnr.ca (Stuart MacMartin)
Newsgroups: comp.lang.c++
Subject: Re: Just what is so great about streams?
Date: 18 Nov 92 13:45:51 GMT
Organization: Bell-Northern Research Ltd., Ottawa, Canada

In article <6994@taurus.cs.nps.navy.mil> skip@taygeta.oc.nps.navy.mil (Skip Carter) writes:
>
>	In this thread about why one should WANT to use streams,
>	there has been a lot said about type-safety, runtime efficiency,
>	and extensibility with regard to I/O for new types.  However I have
>	yet to see anyone mention this advantage:   polymorphism with regard
>	to the I/O stream.
>
>	Consider the following,
>

[class TimeStamp]
>         friend ostream& operator<<(ostream& os, const TimeStamp& t);
>};
>
>class Comment : public ostrstream                   // write a comment to a file, with user defined start and end
>{                                                                             //  comment sequences
>
>	Now the TimeStamp class can write a comment WITH NO CHANGES MADE TO
>	THE TIMESTAMP CLASS.
>
>	Comment fout(...);
>
>	fout << TimeStamp();
>
>
>	In fact, TimeStamp can properly write to any class that is ultimately derived from ostream.
>

What about     fout << t << t << endl;   
The wrong operator<<() will be called for the second output unless you provide
the appropriate friend function for TimeStamp, no?

Stuart

--
: Stuart MacMartin                                    email: sjm@bnr.ca      :
: Bell-Northern Research                              phone: (613) 763-5625  :
: PO Box 3511, Stn C, Ottawa, K1Y-4H7, CANADA    Standard disclaimers apply. :
From: dolgov@inpbox.inp.nsk.su (Yuri V. Dolgov)
Newsgroups: comp.lang.c++
Subject: How to run destructors of all objects when failure exit occurs ?
Date: Thu, 12 Nov 92 20:35:06 +0700
Distribution: world
Organization: Budker Institute of Nuclear Physics SD RAS
Reply-To: dolgov@inpbox.inp.nsk.su

   Dear C++ gurus !

   Often I use failure program exit when some conditions are bad.
The trouble is: I created some objects (e.g. dialog boxes, network connections
and so on) and I want to run destructors before program exit.
Is there exist standard technique in C++ language to solve this problem ?

Thanx in advance,

Yuri Dolgov,

Novosibirsk Institute of Nuclear Physics, Siberia, Russia.
-- 
-------------------------------------------------------------------------------
Yuri Dolgov                               Internet: dolgov@inp.nsk.su
Programmer                                Phone:    +7(3832)359 147
Budker Institute of Nuclear Physics       Novosibirsk, Russia.
From: a036450@rd821.UUCP (Bob Goldrich)
Newsgroups: comp.lang.c++
Subject: Re: Just what is so great about streams?
Date: 19 Nov 92 13:51:39 GMT
Organization: The Gleason Works, Rochester New York
X-Newsreader: Tin 1.1 PL4

I, too, believe that the iostreams, while adding type checking and
extensibility, have lost conciceness.   A simple printf like:
     printf("%6.2lf  %0d   %5.1lf\n", adoub, aint, bdoub) ;
turns into a rather unwieldy piece of code.  The stream libraries would
have been much more useful had their designers attempted to retain some
of printf's "quick-and-dirty" syntax.

Probably the biggest problem is that I haven't seen any *good* comprehensive
documentation on the stream libraries, with examples, etc, etc.

            Bob Goldrich    a036450@rd821.gleason.com

Newsgroups: comp.lang.c++
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: Idempotent header file proposal
Organization: Computer Science, University of Melbourne, Australia
Date: Mon, 23 Nov 1992 02:18:24 GMT

nh@cbnewsg.cb.att.com (nicholas.hounsome) writes:

>One problem with C++ is that when used properly it requires huge
>numbers of header files most of which are included multiple times.
>Of course I know that there is the crude workaround :
>
>#ifndef HEADER_H
>#define HEADER_H
>
>stuff
>
>#endif
>
>But the preprocessor still has to find, open , and read the whole file
>so it does not realy gain you any efficiency.

No it doesn't. The GNU C Preprocessor checks each header file as it is read
in to see whether it matches the above pattern. If so, it avoids reading
the file on second time and subsequent times (unless you #undef HEADER_H).

-- 
Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
This .signature virus is a self-referential statement that is true - but 
you will only be able to consistently believe it if you copy it to your own
.signature file!
From: wbader@pluto.csee.lehigh.edu (William Bader)
Newsgroups: comp.lang.c++
Subject: Re: New Employee Test
Date: 18 Nov 92 01:40:36 GMT
	<1992Nov17.191133.18920@bcrka451.bnr.ca>
Organization: Electrical Engineering and Computer Science, Lehigh University

Where I work, we ask people to write a short program that breaks a line
into words.  Before they start, we have them estimate how long it will
take them.  When they finish, we check the program for basic programming
skills.  (They do it on paper, and very few get it right.)  We also see
how they react to comments as we go over the program.  We try to avoid
hiring people who will be hard to work with.
Newsgroups: comp.lang.c++
From: jbn@lulea.trab.se (Johan Bengtsson)
Newsgroups: comp.lang.c++
Subject: Re: Just what is so great about streams?
Date: 20 Nov 92 11:21:18 GMT
Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
X-Newsreader: Tin 1.1 PL4

mccauleyba@vax1.bham.ac.uk (Brian McCauley) writes:
: In article <1992Nov18.205139.12711@bcrka451.bnr.ca>, sjm@bcrki65.bnr.ca (Stuart MacMartin) writes:
: > 
: > Perhaps I was thinking too general.  If the class of fout does not need to
: > redefine operator<<(), everything is ok.  But if there is some processing
: > that has to be done before the data is passed to the underlying stream, 
: > doesn't the class of fout have to redefine operator<<()?  In which case
: > my example does not work.  Because operator<<() is *not* virtual.  I don't
: > think it is true that TimeStamp can properly write to *any* class that 
: > is ultimately derived from ostream.  And if it can, I'd sure like to know how.
: 
: Yes this is true. This is why classes derived from a stream class should
: _not_ redifine operator<<.  Different stream classes differ only in their
: IO end not their data formatting end.

Which means that stream subclasses are forever restricted to
be simply forwarding classes to streambufs, right?

Kind of shows that the design with separate ios and streambuf hierarchies
is unnecessarily complicated, IMHO.  Anyone care to comment?
-- 
--------------------------------------------------------------------------
| Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden  |
| Johan.Bengtsson@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490  |
--------------------------------------------------------------------------
Newsgroups: comp.lang.c++
From: rmartin@thor.Rational.COM (Bob Martin)
Subject: Re: Complexity in the eyes of the beholder?
Organization: Rational
Date: Fri, 20 Nov 1992 18:02:21 GMT

In my view, you answered your own question in the subject line.
Complexity is often in the eye of the beholder.  What you find to be a
natural expression of a complex system, your friend does not.  Period.
There is no right or wrong here, just individual taste and preference.

If you are really interested in pursuing this question futher, then
get 10 engineers.  Find a complex problem, and have your friend
provide his solution to 5 of the engineers, and you provide your
solution to the other five.  Then ask all 10 engineers to make a
significant modification to the system.  Measure the time it takes to
make the modifications, and the quality of the result (number of
bugs?).  Ignore their groaning and moaning about style.  



--
Robert Martin                        Training courses offered in:
R. C. M. Consulting                       Object Oriented Analysis
2080 Cranbrook Rd.                        Object Oriented Design
Green Oaks, Il 60048 (708) 918-1004       C++
Newsgroups: comp.lang.c++
From: steve@taumet.com (Steve Clamage)
Subject: Re: Nested Templates in g++
Organization: TauMetric Corporation
Date: Mon, 23 Nov 1992 23:33:31 GMT

magerman@watson.ibm.com (David Magerman;046923) writes:


>Using the xlC++ 1.1.1, trying to
>refer to B<A<X,Y>> generates a syntax error, because the compiler
>tries to interpret the >> as an operator.  If I use B<A<X,Y> >, it
>compiles and runs fine.

>However, since you're using g++, this might be irrelevant.  (Could two
>independently written compilers have the same stupid error?)

This is not a compiler error, but the way the language is defined.

In the initial phases of translation of the C++ source program, the
source is broken up into tokens.  A token is the longest sequence
of characters which could be a token.

In the example above, the sequence ">>" is taken to be the single token
">>" and never as the two tokens "> >", no matter what the context.

This concept is not new in C or C++, and appears in K&R1.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Vice Chair, ANSI C++ Committee, X3J16
Newsgroups: comp.lang.c++
From: donley@cscns.com (Donley P'Simer)
Subject: Re: question on REFERENCES
Organization: Community_News_Service
X-Newsreader: Tin 1.1 PL3
Date: Tue, 17 Nov 1992 19:23:02 GMT

kestes@nswc-wo.nswc.navy.mil (Kent Estes) writes:
: Hello netters,  
: 
: I am working on a function that references objects via id.  Upon finding
: an object, it returns a reference to that object.  My question is :
: if the object is not found, what is the best way to handle this.  If 
: I were returning pointers to objects, all I would have to do is
: return NULL.
: 

The way that Borland's Container Class Library does it seems the best way
to me. All BI's container classes are derived from Object. There is a
special instantiation of Object called ZERO. If you do something similiar
you can return a reference to your special error object and even store
error infomation in that object. The user must test all returned
references against this object. When an error is detected the user can
extract error information from it. The following code should give you an
idea of what you can do:

class Object
{
    // your data
public:
    // constuctors, destuctors, and the like.
    int foo() { if (/* there is an error */) return 0; else return 1;}
};

Object ERROR;

Object& bar()
{
    Onject &O;

    /* find an object and reference it by O */
    if !O.foo()
	return ERROR;
    else
	return O;
}

This is totally unfunctional, but I think you can get the picture. I hope
this helps.


-- 
			{-| Donley R. P'Simer |-}

Internet: donley@cscns.com		PSC Box 367
CompuServe: 75540,263			Peterson AFB, CO. 80914-5360
Newsgroups: comp.lang.c++