HDTenEightyP/NetNews huggingface dataset:
From: peter@kentrox.uucp (Peter Uchytil)
Subject: can I 'delete' without a 'new'?
Organization: ADC Kentrox, Portland OR
Date: Fri, 4 Sep 1992 17:10:20 GMT

I can't seem to find any references which indicate whether I can do this
or not, so I'm appealing to the net.wisdom.  Here's what I've got:

class foo {
  char *String;
public:
  foo();
  foo( char * );
  ~foo();
  void set( char * );
};

foo:foo() { };

foo:foo( char *inString ) {
  String = new char[strlen( inString )];
  strcpy( String, inString );
}

void foo:set( char *inString ) {
  String = new char[strlen( inString )];
  strcpy( String, inString );
}

foo:~foo() {
  delete [] String;
}

The question is what will happen if I create a foo with the empty constructor
and never call 'set'?  Since 'new' has never been called, what will 'delete'
try to delete?  Looks like a real good way to frazzle the system.  Yes?  No?

The reason I want to do this is I want to declare an array of 'foo'.  To do
the assignment:
       LotsaFoos foo[100]; 
I have to use an empty constructor.  

One idea I had was to have the empty constructor do something like:
       String = new char[1];

But then does 'set' first have to do a 'delete' before doing another 'new'?
I would assume it does.

Summary of questions:
      1) What happens if I call 'delete' without having called 'new'?  
      2) What happens if I call 'new' twice in a row?  Sounds like I'm going
         to make some memory become unrecoverable.  

Thanks for any comments!

Pete
-- 
Peter Uchytil   | ADC Kentrox Industries | "They say that I'm a dreamer
peter@kentrox.com |  Portland, Oregon    |  And I tell them they are right"
Newsgroups: comp.lang.c++
From: vputz@nyx.cs.du.edu (Victor Putz)
Subject: BC++ 3.1 bitmaps
Summary: Help required
Organization: University of Denver, Dept. of Math & Comp. Sci.
Date: Wed, 9 Sep 92 15:53:56 GMT


S
Sincerest apologies for an IBM-specific question: I need to display
256-color image bitmaps from BC++3.1; any sort of utility/library/hints on
how to edit/create such bitmaps and display them would be appreciated.

Thank you-->vputz@nyx.cs.du.edu

Newsgroups: comp.lang.c++
From: oherb@jhunix.hcf.jhu.edu (Zoher B Bambot)
Subject: Re: General Datastructure Design Question
Organization: HAC - Johns Hopkins University, Baltimore
Date: Thu, 10 Sep 1992 20:34:41 GMT

Hi! I had posted this earlier but due to no suitable response I am posting it
again. I would gratefully acknowledge a reply in this matter.

I am working on developing classes for simulation of finite element meshes
using the object-oriented language c++. I would be grateful if anyone could
send me any programs in c++ which would help me in my work. Also has anyone 
developed a class for the simulation of a FEM for any particular structure.
You can mail them to me at my e-mail address and then I will summarize in
the net. Also are there any ftp sites from where I could get any useful
information. Thanx in advance.
                         Zoher.( oherb@jhunix.hcf.jhu.edu )
Newsgroups: comp.lang.c++
Subject: Swedish Telecom Lab's C++ Style Guide
From: BIELSIKFJ@MAIL.BECKMAN.COM (Frank J Bielsik)
Date: Tue, 15 Sep 1992 00:56:51 GMT
Organization: Beckman Instruments Inc. 2500 Harbor Blvd. Fullerton, CA 92634

I'm trying to locate a document called "Programming in C++: Rules and 
Recommendations" from "Elemental Telecomm Systems Lab" in Sweden.  Has 
anyone heard of such a place and/or document, and how I could get it?

Thanks.
Newsgroups: comp.lang.c++
From: ppc1@cec1.wustl.edu (Peter Pui Tak Chiu)
Subject: FULL HOUSE (REVISED)
Organization: Washington University, St. Louis MO
Date: Sun, 13 Sep 1992 22:34:25 GMT



// this previous version of this program assumes that we are drawing from
// an infinite deck.  (which is a bug).

// now this version has no such problem...
// but still the probability is around 0.004...
// which is four times the theoretical value 0.001441

// what's wrong???!!!

#include <iostream.h>
#include <time.h>
#include <stdlib.h>
#include <math.h>

static int hand[5];
long COUNTER=0, GOOD=0;

int getRandom(){
int n,BAD=1;
while(BAD){
n=rand()%52+1;
for(int i=0;i<5;i++){
	int FLAG=0;
	if(n==hand[i])FLAG=1;
	if(!FLAG)BAD=0;
	}}
return(n);
}

void init(){
for(int i=0;i<5;i++)hand[i]=0;
for(i=0;i<5;i++)hand[i]=getRandom();
for(i=0;i<5;i++)hand[i]=hand[i]%13;
}

int fullhouse(){
int counter[13],flag2=0,flag3=0;
for(int i=0;i<13;i++)counter[i]=0;
for(i=0;i<5;i++)counter[hand[i]]++;
for(i=0;i<13;i++){
	if(counter[i]==2)flag2++;
	if(counter[i]==3)flag3++;
	}
return(flag2&&flag3);
}

main(){
randomize();
while(1){
COUNTER++;
init();
if(fullhouse())GOOD++;
if(!fmod(COUNTER,10000))cerr<<COUNTER<<double(GOOD)/COUNTER<<"\n";
}}


Newsgroups: comp.lang.c++
From: dave@objy20.Objy.COM (Dave Hu)
Subject: Parc Place & Solbourne
Reply-To: dave@objy.com
Organization: Objectivity Inc.
Date: Tue, 15 Sep 92 23:16:44 GMT

Hi,

I've heard a rumor that Parc Place Systems has acquired the software division
of Solbourne computer. Can anyone confirm this? If true, it could mean some
interesting changes in the C++/GUI development environment marketplace.

Thanks in advance...

Dave.
Newsgroups: comp.lang.c++
From: sjm@bcrki65.bnr.ca (Stuart MacMartin)
Subject: Re: zero-length datatype
Organization: Bell-Northern Research Ltd., Ottawa, Canada
Distribution: comp
Date: Tue, 15 Sep 1992 13:35:03 GMT

There are a few problems with void objects of 0 size.
These are all related to the question: "How do I handle references
from one object to a void object?".  

1. Databases need to have a unique object id for each object.
   Many oid schemes include an offset into a data record.

   Databases could be changed to support void, but many would
   do this by allocating storage for void objects anyway.

2. Ditto for in-core and pointers.  Are the addresses of different
   void values going to be different?  (Or is there exactly one
   void value?)

3. Some implementations of malloc do not work with 0 bytes.
   And what should malloc (or new) return in this case?
   See points 2 and 4.  Is the solution for malloc to allocate
   one byte in this case?

4. If we decide that there is only (exactly) one void object, then
   what should its id/address be?  Will this conflict with any
   database or program?  Must C++ specify the id in this case?
   Can it?

5. What does (void *) mean?  Generic pointer, or pointer to a type
   of size 0?

One way of handling these difficulties might be to say that void is a
base type that cannot be instantiated.  It can be part of a template
definition, but cannot be created, passed or returned.  That is,
returning a void has the same meaning as now: it is not returning
a parameter.  This adds yet another special case to the language.

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: munroe@dmc.com (Dick Munroe)
Newsgroups: comp.lang.c++,gnu.g++
Subject: Re: Variable Declarations
Date: 10 Sep 92 08:35:02 EDT
Organization: Doyle, Munroe Consultants, Inc., Hudson, MA

In article <u895217.716089910@bruny>, u895217@bruny.cc.utas.edu.au (Scott Marshall) writes:
> Hi.
> I need a little advice on using C++. When given the following code, would
> the variable being declared (and initialised) be re-initialised on every
> iteration?
> 
> 		String s = buf;

It will be reinitialized with each iteration of the loop.  This statement is
equivalent to (begging the issues of constructors):

        String s ;
        s = buf ;
-- 
Dick Munroe				Internet: munroe@dmc.com
Doyle Munroe Consultants, Inc.		UUCP: ...uunet!thehulk!munroe
267 Cox St.				Office: (508) 568-1618
Hudson, Ma.				FAX: (508) 562-1133

GET CONNECTED!!! Send mail to info@dmc.com to find out about DMConnection.
Newsgroups: comp.lang.c++
From: farrar@adaclabs.com (Stephen Daedalus)
Subject: Porting from C to C++
Keywords: port
Organization: The Eye of the Pyramid, Inc.
Date: Fri, 11 Sep 1992 00:38:44 GMT

I am looking for testimonials from people that have ported large systems,
i.e. more that 500,000 lines of C code.  We are trying to sell our mangement
on the idea, but we need to present them with the pros and cons.  How long
did it take?  How many people?  What were the benefits?  Do you think it
is paying off?  Quantitative data is most desirable, such as the following:
The number of bugs per week went down from X to Y.
The debugging time went down from X to Y.
The time to develop a new application went from X to Y.
Etc.
Please email me directly.  If I feel the responses are appropriate, I will post
a summary.
This may not be the proper newsgroup for this.  Is there a comp.c++.advocacy?
---
Richard Farrar		These views are my own, not my company's or country's.
ADAC Laboratories	"A man without hand is not a man."
farrar@adaclabs.com		- George Costanza, Seinfeld
Newsgroups: comp.lang.c++
From: etxpihl@eua.ericsson.se (Tomas Pihl)
Subject: Re: Swedish Telecom Lab's C++ Style Guide
Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden
Date: Tue, 15 Sep 1992 06:19:11 GMT

In <BIELSIKFJ.8@MAIL.BECKMAN.COM> BIELSIKFJ@MAIL.BECKMAN.COM (Frank J Bielsik) writes:

>I'm trying to locate a document called "Programming in C++: Rules and 
>Recommendations" from "Elemental Telecomm Systems Lab" in Sweden.  Has 
>anyone heard of such a place and/or document, and how I could get it?

Anonymous FTP to euagate.ericsson.se. (pub/eua/c++)


--
--
Tomas Pihl /  Ellemtel Telecom Systems Labs - Stockholm, Sweden
          / etxpihl@eua.ericsson.se  FidoNet: 2:201/628

Newsgroups: comp.lang.c++
From: feustel@netcom.com (David Feustel)
Subject: Re: Looking for a good C++ book...
Date: Tue, 15 Sep 92 23:35:52 GMT
Organization: DAFCO: OS/2 Software Support & Consulting
Keywords: help C++ books

I would recommend highly Coplien's book "Advanced C++" too. The only
thing I miss in this book is a discussion of and solution to the
problem of persistant objects.
-- 
Dave Feustel N9MYI <feustel@netcom.com>
 
RE Drug Warriors who enjoy making a "good" bust: I'm sure the Salem
Witch Hunters enjoyed their law enforcement achievements too.
From: harris@hprnd.rose.hp.com (Mike Harris)
Date: Tue, 15 Sep 1992 00:08:47 GMT
Subject: Template Code Generation
Organization: HP Roseville Networks Division
Newsgroups: comp.lang.c++

I am using the USL components and building a library which uses some
of the container classes.  I have periodically got unresolved code when
linking with this library.

What do I need to do to make sure that the linker knows about and can
generate code for a library that uses templates ?  Is there any best
way to implement or use a library that needs the linker to generate template
code ?

Please e-mail any responses.

Thanks,

Mike
Hewlett Packard
harris@hprnd.rose.hp.com
From: tmb@arolla.idiap.ch (Thomas M. Breuel)
Newsgroups: comp.lang.c++
Subject: Re: zero-length datatype
Date: 13 Sep 92 01:29:03 GMT
	<23659@alice.att.com>
Reply-To: tmb@idiap.ch
Distribution: comp
Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
	Perceptive)
In-reply-to: ark@alice.att.com's message of 12 Sep 92 15:54:04 GMT

In article <23659@alice.att.com> ark@alice.att.com (Andrew Koenig) writes:

   In article <1992Sep11.185505.17536@cadsun.corp.mot.com> shang@corp.mot.com writes:

   > That is why ISO C standard does not allow empty structure and zero 
   > number of array.

   No, ISO C does allow empty structures.  It just says that they must
   occupy a non-zero amount of memory.

   > But I don't see the reason why we can't have zero-size objects. Don't 
   > say that the standard explicitly says that. I want to know why it says 
   > that. So far, I haven't heard any convincing argument.

   I don't really know why.  What I do know is that the presence of
   that requirement in the C standard makes it hard to avoid the same
   requirement in the C++ standard.

Well, it might be good to remain compatible, in the sense that every
object that has non-zero size in ISO C also have a non-zero size in
C++. However, since there are no objects of type "void" (or of some
other, newly introduced, distinguished type with zero size) in ISO C,
there can't be any harm in letting objects of this new type have zero
size: the behavior of existing code would not be affected.

					Thomas.
Newsgroups: comp.lang.c++
From: steve@taumet.com (Steve Clamage)
Subject: Re: Answers on a postcard...
Organization: TauMetric Corporation
Date: Tue, 15 Sep 1992 17:03:55 GMT

sg3235@sw1sta.uucp (Stephen Gevers) writes:

[   my comments that left-to-right evaluation is not guaranteed for
    an overloaded comma
]
>While I understand Mr. Clamage's explanation, I do not see any support of it
>in the ARM.

Section 13.4, page 330 (not commentary):

"The predefined meaning of the operators =, (unary) &, and , (comma)
applied to class objects may be changed."

-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Vice Chair, ANSI C++ Committee, X3J16
From: gonzalod@amex-trs.com (Gonzalo Diethelm)
Newsgroups: comp.lang.c++
Subject: yacc and C identifiers
Date: 5 Sep 92 01:34:52 GMT



Distribution: world

Hello everyone,

Two questions about yacc. Assume I'm trying to implement a C compiler:

1. How do you handle identifiers? By this I mean, let's say the
   lexer stores identifiers in the symbol table and returns an ID token
   to the parser, how do I access the identifier from the parser?
   What I'm doing now is having a production

     id : ID
          {
            $$ = yylval;
          }

   where the lexer sets yylval to the position in the symbol table
   the identifier is stored in. This works, but I'm not sure it is
   the correct approach. I know I could define the type of the parser
   stack to be a union and store there the value of the identifier
   (position in symbol table?). Which approach is better? Is there
   another solution superior to any of these?

2. How would you handle name spaces? For example, how could you differentiate
   between the var in

     int   var;

  and the var in

     struct s { int var; };

  or, even better, between all these vars

    struct s1
    {
      int var;
      struct s2
      {
        int var;
        union  u1
        {
          int var;
          float f;
        }
      }
    }

  I CAN think of ways to do this, but somehow I feel the parser itself
  has enough information stored in its states to handle the name spaces.

Any pointers are welcome. Examples are preferred... 8^). Thanks in advance.


gonzalod@amexphx.amex-trs.com
Gonzalo A. Diethelm                 (602)375-8410  home
16220 N 7th St Ap 1314              (602)492-3536  office
Phoenix, AZ 85022                   (602)492-4248  FAX
From: ark@alice.att.com (Andrew Koenig)
Newsgroups: comp.lang.c++
Subject: Re: zero-length datatype
Date: 10 Sep 92 17:36:24 GMT
Reply-To: ark@alice.UUCP ()
Distribution: comp
Organization: AT&T Bell Laboratories, Murray Hill NJ

There is one problem with `void' as a true datatype that I have not
been able to solve: ISO C says that

	void f(void);

is a function with no arguments at all and C++ therefore follows suit.
Making void into a true type would therefore require some compatibility
warts; it is not clear exactly what would be necessary or what effect it
would have on the rest of the language.
-- 
				--Andrew Koenig
				  ark@europa.att.com
Newsgroups: comp.lang.c++
From: euamts@eua.ericsson.se (Mats Henricson)
Subject: How to get it, Was: Ellemtel C++ Style Guide
Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden
Date: Tue, 15 Sep 1992 16:43:28 GMT

Below is a description on how to get the document.

Mats Henricson
Ellemtel
Stockholm
Sweden

========================================================================
"Public Domain" Coding standards for C++ in ENGLISH

Hi!

Our programming standard for C++ has finally been translated to English.
In addition, some minor changes have been made. We believe that this
version is rather stable, so that the next version should not be expected
for quite a while.

Many people have aversions against programming standards. We recognize this
and have therefore tried to make our document as flexible as possible.
We have a set of 51 RULES (sometimes with exceptions) which we do not see
any reason not to follow. Then we have a set of 79 RECOMMENDATIONS. They
are meant as guidelines. We belive that most code should follow these
recommendations, but we have ourselves recognized times when braking these
recommendations are not only appropriate, but also necessary.

To you who really hate programming rules: we challenge you to try to
reduce the number. We would be all too happy if you succeed, since we too
are programmers and dislike rules ourselves.

The document only touches the subject of C++ design. The chapter on
portability is sketchy. We have also tried to avoid subjects that we
believe belong to an introductionary course in C++. 

The document contains 70 code examples. Many are simple, but some are
quite complex. Most examples are possible to compile directly, while some
may need some more or less obvious extra code to make sense for the
compiler.

The document has the same copyright notice as the cool library,
i.e. it is OK to copy and use the document, but we retain the copyrights.
Also, we provide no warranty at all. If any of our code examples destroy
your network, we will simply say "Sorry!".

The document was written using FrameMaker, but has been saved in Postscript
and compressed. It can be accessed by anonymous ftp from our server:
   euagate.eua.ericsson.se   (Internet Address: 134.138.134.16)
It is in the directory:
   ~ftp/pub/eua/c++
The file is ~126k large and its name is:
   rules.ps.Z
   
If there are any problems in accessing or printing the file, please contact
us at:
   mats.henricson@eua.ericsson.se

All comments are welcome. Especially if you find any bugs or
misunderstandings from our side. Please make it clear which version
you have comments on, i.e. if you have comments on this version
state "Version C in English" somewhere.

Erik Nyquist
Mats Henricson

Ellemtel
Box 1505
125 25 Alvsjo
Sweden
From: rmartin@thor.Rational.COM (Bob Martin)
Newsgroups: comp.lang.c++
Subject: Re: GOTO, was: Tiny proposal for named loops.
Date: 11 Sep 92 00:09:03 GMT

mccall@mksol.dseg.ti.com (fred j mccall 575-3539) writes:

|In <rmartin.715618743@thor> rmartin@thor.Rational.COM (Bob Martin) writes:

|Sorry, but that's hardly the reason.  Where is the 'coupling' or the
|difficulty in maintenance when goto is used for things like error
|handling or error returns? 

The coupling is between the error condition, and the error processing.
The error processing control flow is merged with the separate control
flows which detect the error.  

These merged control flows get difficult to maintain over time,
because new error conditions arise which need to be handled in almost
the same way, but with a few exceptions.  These exceptions accumulate
in the merged code, and it eventually turns into a nightmare until
someone undoes all the gotos and separates all the error processing.

|>The last thing I advocate is a reduction of all code to one linear
|>stream of sequence, selection and repetition.  

|But that is exactly your rataionale for why structured programming
|'works'; that it is possible to implement anything using sequence,
|selection, and repetition.

I should add 'procedure call' to that list.  Or perhaps method
invocation.  

--
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++
From: jbn@lulea.trab.se (Johan Bengtsson)
Newsgroups: comp.lang.c++
Subject: Re: zero-length datatype
Date: 9 Sep 92 19:58:05 GMT
Distribution: comp
Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
X-Newsreader: Tin 1.1 PL4

tmb@arolla.idiap.ch (Thomas M. Breuel) writes:
: In article <MCGRANT.92Sep7142456@rascals.stanford.edu> mcgrant@rascals.stanford.edu (Michael C. Grant) writes:
: 
:    I don't understand why those 4 bytes are causing you such a stink. Perhaps
:    you could enlighten us as to why a truly zero length data type is even
:    necessary?
: 
: Under the current rules,
: 
:       struct nothing {};
:       HashTable<int,nothing> table(1000000);
: 
: table takes up 8Mbytes (on most machines). If you could write
: 
:       HashTable<int,void> table(1000000);
: 
: table takes up 4Mbytes.

Note also that the "minimum 4 bytes" effect multiplies, if
a class has more than one "void" data member:

// This is not legal C++ code, "void" means "zero-size type"
class C {
	long i;
	void a,b,c,d,e;
};

On common implementations, 1 million such objects take up
24 MB (since a-e take up 4 bytes each), whereas Thomas's
proposed 'void' type means only 4 MB would be needed.
Quite a difference!

Side note: As everybody knows, a similar size blowup occurs
when small-size classes are given virtual methods, and those
classes are used as data members in other classes. This is a
good reason why not every class should have virtual methods.

Of course, a zero-size data type is not "necessary" (only wins
you some memory), but it might be useful, IMHO.

-- 
--------------------------------------------------------------------------
| Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden  |
| Johan.Bengtsson@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490  |
--------------------------------------------------------------------------
From: murakami@idas.imslab.co.jp (Mr.Murakami)
Newsgroups: comp.lang.c++
Subject: Re: APIs across Sun, Mac, and PC?
Date: 14 Sep 92 03:24:30 GMT
Organization: Information and Mathematical Science Lab. Inc., Tokyo, Japan

In article <1992Sep10.175657.13369@parc.xerox.com>, fromherz@parc.xerox.com (Markus Fromherz) writes:
> What development environments, class libraries, application frameworks
> or APIs exist that allow to write programs portable across Suns, Macs
> and PCs?

  Hello. My Name is Murakami, Yukio.
  I can speak English, a little.

  I think...
  This is Bedlock!
  It's for Macintosh and MS-Windows.
  But, it is No Looking.
  We see too far!!

  Thank you.

-- 
$B4d@P@83h<T(J		Yukio Murakami@idas.imslab.co.jp
From: eeron@techunix.technion.ac.il (Ron Daisy)
Newsgroups: comp.lang.c++
Subject: A vector class problem. Help!
Date: 9 Sep 92 10:05:09 GMT
Reply-To: eeron@techunix.technion.ac.il (Ron Daisy)
Organization: Technion, Israel Inst. of Technology

I want to have a vector class and to overload operators on it.
I tryed the following structure:

typedef float VecTerm;
typedef VecTerm *vec;
class vector {
  private:
    vec v;
    int dim;
  public:
    vector(int);
    ~vector(void);
    vector operator = (const vector& ) ;
    float& operator[](int) const;
    int size() const;
    vector operator + (const vector& x) const;
	.
	.
	.
};

The body of the operators is given by:

   inline vector::vector(int n)
   {
     assert(n>0);
     v = new VecTerm[n];
     assert( v != 0);
     dim = n;
   }
   vector::~vector(void) {
     delete  v;
   }

   inline vector  vector::operator = (const vector& x)
   {
      assert(dim == x.dim);
      dim = x.dim;
      v = x.v;
      return *this;
   }

   inline float& vector::operator[] (int n) const {
     assert( (n >= 0) && (n < this->dim) );
     return *(v + n);
   }

   int vector::size(void) const { return dim; }
  
   vector vector::operator + ( const vector& x) const
   {
     int i;
     assert( x.dim == dim );
     vector result(x.dim);
     for (i = 0; i < x.dim; i++)
     {
       result[i] = *(x.v+i) + *(v+i);
     };
     return result; 
   };

    When i tryed to run it and to use the '+' operator, it behaved very
strangely. The first two elements of the answer vector were wrong, and the rest 
were OK.
   When i ran a debuger i understood that the reson for this "strange" behavior
is the destructor. My mistake is the return of local vector (result) which was
destructed after the operator call was ended. This destruction is critical
since the returned vector contain a pointer!

Do some one has an idea how can i solve this problem?

Thanx!
Newsgroups: comp.lang.c++