HDTenEightyP/NetNews huggingface dataset:
From: steve@eowyn.gte.com (Steve Preston)
Newsgroups: comp.lang.c++
Subject: Destructor called without constructor -- is this a bug?
Date: 30 Sep 92 02:14:59 GMT
Organization: GTE Laboratories

I am taking a C++ course and this was one of the examples.
------------------------------Integer.h------------------------------
class Integer {
public:
     Integer();  /* this malloc's memory and assigns ptr */
     ~Integer(); /* this free's ptr */
     void print() const;

     Integer operator=(int);
     Integer operator=(const Integer &);

     friend Integer operator+(Integer, Integer);
     friend Integer operator-(Integer, Integer);

private:
     int *ptr;
};
----------------------------------------------------------------------
I will omit the function definitions.  Here is the main function.
----------------------------------------------------------------------
#include "Integer.h"
#include <stdio.h>

main(int, char *[])
{
     Integer i, j, k;

     i = 2;
     j = 3;
     k = i + j;

     i.print(); printf("\n");
     j.print(); printf("\n");
     k.print(); printf("\n");

     return 0;
}
----------------------------------------------------------------------
I found that the destructor was being called after the two assignments
that use operator=(int).  There were no corresponding constructor
calls.

This resulted in memory being prematurely/multiply free'd.

Is this a bug in g++?

PS. I noticed that if I took out the operator=(const Integer &)
function that there were no superfluous destructor calls.
--
--
Steve Preston (scp2@gte.com)
From: c23rrj@kocrsv01.delcoelect.com (Rajnish Joshi)
Newsgroups: comp.lang.c++
Subject: C++ Vs C for a GUI
Date: 30 Sep 92 17:37:21 GMT
Organization: Delco Electronics Corp.
Originator: c23rrj@kocrsw04


HELP !!

I am not quite familiar with C++. I will appreciate it a lot if
someone will tell me some distinct advantages of C++ over C .
We are using X/Motif to develop a GUI for a large application & we have to
make a selection between C and C++.


Thanks for your time

RAJ
-- 
**************************************************************************
  Rajnish Joshi              Phone: (317) 451-0643   GM Line: 8-322-0643
  Software Technology         UUCP: deaes!c23rrj
  Delco Electronics Corp.    Internet: c23rrj@kocrsv01.delcoelect.com
From: dolson@plains.NoDak.edu (Daniel Olson)
Newsgroups: comp.lang.c++
Subject: Turbo Power's C++ Object Library
Summary: Information request
Keywords: C++ Libraries
Date: 2 Oct 92 19:36:33 GMT
Organization: North Dakota Higher Education Computing Network


 I am looking for some advice on C++ object libraries for Borlands C++.

I already have the Pascal version or Turbo Power's Object Professional and
have been for the most part pleased with it.

I understand that they have a C++ version but I have been unable to get a
review of Object Pro C++, and Turbo Power's sales people were unable to answer 
these simple questions.
  1) What features other the TSR's were not included in the basic C++ 
  package.
  2) Do they include a menu and screen generator similar to their Pascal 
package (makemenu and makescrn).
  3) Was the C++ package "ported" from Pascal, or was it re-designed to make 
  use of C++'s features?

If I can get away with using this package, it should save me some time on the
learning curve. 

 Has anyone out there used them both?  or just OP C++? If so, please E-mail
 me your opinions/answers.


Thanks
 Dan Olson
-- 
    dolson@plains.NoDak.edu   | Insert sense of humor here.
              or              | Disclaimer: 
    dolson@ndsuext.NoDak.edu  | Next time I'll use a Spell checker.
____________________________________________________________________________
From: maffeis@ifi.unizh.ch (Silvano Maffeis)
Newsgroups: comp.lang.c++
Subject: Pointer to C++ method in C
Date: 2 Oct 92 10:57:47 GMT
Distribution: comp.lang.c++
Organization: University of Zurich, Department of Computer Science

Hello!

I need to call a C++ method from within a C module by using a
C-pointer-to-function. I do that by passing "this" as first (implicit) 
parameter. This may not be very portable.

What is a more portable way of achieving the same effect?
Will the standard C++ parameter passing convention consider
such problems?

thanks for your comments!
silvano


-- 
Silvano Maffeis       CS Dept. University of Zurich, Switzerland
   RFC822: maffeis@ifi.unizh.ch            voice: +411 257 43 27
   X.400: /S=maffeis/OU=ifi/O=unizh/PRMD=SWITCH/ADMD=ARCOM/C=CH/
Xref: sparky comp.lang.c++:14506 comp.std.c++:1298
From: ark@alice.att.com (Andrew Koenig)
Newsgroups: comp.lang.c++,comp.std.c++
Subject: Re: The concept of templates considered ill designed
Date: 4 Oct 92 21:34:56 GMT
Article-I.D.: alice.23796
Reply-To: ark@alice.UUCP ()
Organization: AT&T Bell Laboratories, Murray Hill NJ

In article <BvM0DE.EA7@watcgl.uwaterloo.ca> pfbertra@watcgl.uwaterloo.ca (Philippe F. Bertrand) writes:

> Also for code hiding, compilers should generate intermediate files for
> templated code so that user's of a template class do not need to have access
> to the source.

This is primarily an implementation issue, not alnaugae issue.
If enough people want compilers that behave that way, someone will
create one.
-- 
				--Andrew Koenig
				  ark@europa.att.com
Newsgroups: comp.lang.c++
From: LANG@nvdv01.ind.e-technik.uni-stuttgart.de (MARTIN LANG)
Subject: static member and access control?
Organization: University of Stuttgart, IND (FRG)
Date: Mon, 5 Oct 1992 12:50:39 GMT
X-News-Reader: VMS NEWS 1.23


Follwing a short class declaration with a private static field of an
enumaration type. The enumaration is also declared private. The question
now is: is the initialization illegal or not.

I have tried it with two different compilers. Cfront compiles without
error, Zortech complains because the enumaration is private. The ARM is
not quite clear at this point. In chapter 11 page 239 it states:

   private: that is, its name can be used only by member functions and
	         friends of the class in which it is declared.

In my opinion a static member is neither a member function nor a friends.
Does this mean that Cfront is wrong?

class Test
{
	private:
		enum E1 { a,b};
		static E1 e;
};


E1 Test::e=Test::a;



Thanks,

Martin Lang
University of Stuttgart
From: nh@cbnewsg.cb.att.com (nicholas.hounsome)
Newsgroups: comp.lang.c++
Subject: Re: Persistance Problem Solved by Memory-Mapped Files?
Date: 6 Oct 92 08:31:30 GMT
Organization: AT&T

From article <5043@holden.lulea.trab.se>, by jbn@lulea.trab.se (Johan Bengtsson):
> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
> : 
> : 	But what is a pointer to a non-persistent object
> : doing in a persistent one? A cache perhaps?
> 
> Yes, it would be very nice to be able to have a transient pointer slot
> in persistent objects, to point to a cache.  The transient pointer
> should be nulled on disk, so that the next time the persistent
> object has been mapped in, a new transient cache can be allocated.
> 
> My question is: are there OODBMS that support automatic nullifying (on disk)
> of pointers to transient memory in persistent objects?

Objectstore automaticaly sets them to null (or can do - I am not sure
if it is optional) and you can optionaly get a runtime exception when it does
so.

> 
> The alternative seems to be hash tables, mapping persistent objects
> to transient cache structures, or "cache envelopes" (smart ptrs).
> 
> -- 
> --------------------------------------------------------------------------
> | Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden  |
> | Johan.Bengtsson@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490  |
> --------------------------------------------------------------------------
From: berrios@aps.anl.gov (Joe Berrios)
Newsgroups: comp.lang.c++
Subject: Re: Good book on C++
Date: 29 Sep 92 18:34:15 GMT
Article-I.D.: mcs.1992Sep29.183415.5714
Reply-To: berrios@aps.anl.gov
Organization: Argonne National Lab -- APS

In article 717721582@mont, stephen@mont.cs.missouri.edu (Stephen Montgomery-Smith) writes:
>What is the `definitive' C++ book?  Or at least, is there a complete
>book on C++ that is fast paced, something like K&R on C.

The `definitive' C++ book is: the C++ programming language, 2nd edition, by
Bjarne Stroustrup, the author is the designer and implementor of C++.
Newsgroups: comp.lang.c++,comp.unix.programmer
From: moudgill@cs.cornell.edu ( Mayan Moudgill)
Subject: C++ socket library
Summary: Info/feedback
Organization: Cornell Univ. CS Dept, Ithaca NY 14853
Date: Tue, 6 Oct 1992 18:15:57 GMT

You can get the latest version of the socket library from
  ftp.cs.cornell.edu a.k.a. ramses.cs.cornell.edu a.k.a. 128.84.218.75
in directory 
  pub/sockets
as files
  sstream1.shar & sstream2.shar

This latest version (of Oct 2nd) enhances bufferred sockets. Among other things,
sync() reads everything available in a socket into its buffer.

It should also be available from
  ftp.th-darmstadt.de
in
  pub/programming/languages/C++/class-libraries/sockets/
thanks to Joachim Schord (schord@iti.informatik.th-darmstatd.de)

Yes, I do respond to e-mail requests to have it mailed to me.
But *please* try and ftp it before asking!

Could the people who are using the sockstream library PLEASE, PLEASE,
send me feedback.
I'd like to know
   1] Grouses, complaints, awkwardness.
   2] Suggestions for enchancements.
   3] What they're using it for.

Thanks!
:)
Mayan
(moudgill@cs.cornell.edu)
From: ren@function.mps.ohio-state.edu (Liming Ren)
Newsgroups: comp.lang.c++
Subject: Re: What cout has done to my code? and new questions.
Date: 29 Sep 1992 11:45:39 -0400
Organization: Department of Mathematics, The Ohio State University
Distribution: usa
NNTP-Posting-Host: function.mps.ohio-state.edu

>|> #define WORDSIZE 32
>|> typedef unsigned int *BitVec;           

>|> class BitVector{
>|>  public:
>|>   BitVector(int=WORDSIZE, int=0);
>|>   ~BitVector(){delete [] bv;};
>|>   BitVector operator~() const;  
>|>   //~ return the complement of the bitvector;
>|>   show();
>|>  private:
>|>   BitVec bv;
>|>   unsigned short size; //bit length of the bitvector;
>|>   short wordWidth; // wordlength of the bitvector;
>|>   };
>|> 
>|> BitVector BitVector::operator~() const
>|> {
>|>   //bitwise negation operation;
>|>   BitVector result(size, 0);
>|>   BitVec tmp=result.bv;
>|>   for(int i=0; i<wordWidth; i++)
>|>     {
>|>       *(tmp+i)=~(*(bv+i));
>|>     }
>|>   cout<<wordWidth<<" "<<sizeof(*(tmp+i))<<endl;
>|>   //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^;
>|>   //*************the above line causes the problem**********
>|>   return result;
>|> }
>...
>|> main()
>|> {
>|>   BitVector bb(32, 1);
>|>   BitVector bc=~bb;
>               ^^^
>Here you have an implicit call to the BitVector copy constructor.
>Since you haven't defined one, a default copy constructor is used.
>It copies the pointer BitVec bv, but doesn't copy the array that
>bv points to. To avoid random results, define a copy constructor
>explicitly and have it create and initialze a new array for bv.
>

Thanks peter for your help. I add the copy constructor as you mentioned and it
works fine. BUT i still did not understand this fully. Could you or somebody
else expand on it more and help me about the following question:

 (1) As far as I read from Lippman's book (OK, it is not a
good book), the class uses memberwise initialization if no copy constructor 
is defined and any free store space allocated by new will not disappear unless
deleted explicitly. Using memberwise initialization in   bc=~bb; this means 
now bc.bv points to the space allocated to result.bv even after variable result
exits its scope (not the space allocated). So bc should have the correct 
result anyway. WHY not?


 (2) After I define the copy constructor, in 
	BitVector bc=~bb;
new space is allocated to bc. It seems to me the space allocated to result 
inside the  function is never claimed back. Can we and how to claim it back?

 (3) In Lippman's book (page 332, second edition), there is a definion
of bitwise AND operation as follows:


// bitwise AND operation;
BitVector BitVector::operator&(const BitVector& b)const
{
  BitVector result(size, OFF);
  BitVec tmp=result.bv;
  for(int i=0; i<wordWidth; i++)
    *(tmp+i)=*(bv+i)&*(b.bv+i);
  return result;
}

He did not define a copy constructor and it works fine to me. My bitwise
negation operator is defined similarly. Why Did I run into random result?



Thanks again!
Organization: Middle East Technical University - Computer Center
Date: Tuesday, 29 Sep 1992 17:25:40 TUR
From: <C51881@TRMETU.BITNET>
Newsgroups: comp.lang.c++
Subject: Dynamic Linker for C++ is wanted!

Hi,
Is there any public domain dynamic linker for C++ in SunOS (Sun sparcs)
environment? If there is can you send the FTP adress?
Thank you ...
                              Budak Arpinar
                         <C51881@TRMETU.BITNET>
Newsgroups: comp.lang.c++
From: frank@Cookie.secapl.com (Frank Adams)
Subject: Re: declare keyword, type inference
Date: Tue, 06 Oct 1992 01:00:37 GMT
Organization: Security APL, Inc.

In article <TMB.92Oct4201915@arolla.idiap.ch> tmb@idiap.ch writes:
>It's not so clear to me that in the presence of a "declare" keyword,
>you couldn't get circular dependencies. For example, what about:
>
>	declare x = f(&x);

This need not be a fatal objection to this proposal.  We can make the
statement above illegal, without making:

     int x = f(&x);

illegal.  I think the "declare" recursion should be outright illegal,
regardless of whether the overloading mechanism produces an ambiguity or
not.
From: checker@acf5.NYU.EDU (checker)
Newsgroups: comp.lang.c++
Subject: Re: question about delete
Date: 3 Oct 92 01:58:45 GMT
Organization: New York University

heilig@plains.NoDak.edu (Zachary Heilig) writes:
>You would think that since
>I deleted foo it would be NULL, or at least still point to the same spot
>in memory, but evidentally, it doesn't even do that.  Where is foo pointing?

The value of the pointer is undefined if the pointer is a modifiable
lvalue.  See ARM 5.3.4.

Chris
Newsgroups: comp.lang.c++,comp.std.c++
From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
Subject: Re: The concept of templates considered ill designed
Organization: MAXTAL P/L C/- University Computing Centre, Sydney
Date: Fri, 2 Oct 1992 15:38:26 GMT

In article <1992Oct1.140643.9775@cadsun.corp.mot.com> shang@corp.mot.com writes:
>
>Thank you, Raymond, for raising this thread. I'd like to fork it
>to comp.std.c++ for standard committee to reconsider whether template should be  
>accepted as C++ standard.

	How would you modify the template idea to be better?

>
>In article <stefans.717754437@bauv106> stefans@bauv106.bauv.unibw-muenchen.de  
>(Stefan Schwarz) writes:
>
>> Would be interesting to hear from library-developers about shipping their
>> products together with source-code.
>
>Right to the point. Would be interesting also to hear about from the  
>library-users about reading the source code to detect where are the source of  
>the usage error.
>
>Template is not a self-enclosed type-safe language feature, i.e. it cannot be  
>compiled separately to ensure type-error free. All type errors about the class  
>parameters are checked when the template is used. When the library-developers  
>ship their products, they cannot ensure their templates are type-error free.  

	This is not true, of course they can. What you mean
is that the compiler doesn't help very much, and I agree.
But I'm sure one could prove that a template was error free
by hand ( I agree this is not formal system like a compiler check,
but lets not get into whether a proof actually proves what it purports
to or not: the usual solution to this problem is to publish the
proof ).

>The library user will get confused when an error is reported on the source code  
>of the template: "should it be my fault or the fault of the template itself?"
>
>In sense of the relationship between developer and user, template is something  
>like untyped function (I don't refer to run-time type error).
>
>David Shang

	I agree but am too stupid to see how the situation could be
improved. For a template class C, it will be the case that

	C<T1>  makes sense
	C<T2>  is illegal

depending on T1 and T2. One cant check that until use, unless
perhaps you have to predeclare:

	class C<T1>; // causes expansion NOW!

-- 
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
Newsgroups: comp.lang.c++
From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
Subject: Re: Persistance Problem Solved by Memory-Mapped Files?
Organization: MAXTAL P/L C/- University Computing Centre, Sydney
Date: Fri, 2 Oct 1992 15:26:24 GMT

In article <dingelde.717962777@putzl> dingelde@igd.fhg.de (Dennis Dingeldein) writes:
>Hi,
>
>feustel@netcom.com (David Feustel) writes:
>
>>I'm wondering whether the problem of persistant objects could be
>>solved by use of memory-mapped files to store the C++ data structures
>>used by C++ programs. Comments?
>
>No, this gives no general solution. Consider objects with pointers 
>to other objects as instance variables. This memory-mapped pointer
>is meaningless to another process accessing the mapped object (the
>pointer makes sense only in the process who writes the object).

	But what is a pointer to a non-persistent object
doing in a persistent one? A cache perhaps? Remember the
persistenty object must retain its state when the processes
die, so perhaps the above cant really happen in persistent
objects?
>

-- 
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
From: jbn@lulea.trab.se (Johan Bengtsson)
Newsgroups: comp.lang.c++
Subject: Re: declare keyword, type inference
Date: 5 Oct 92 11:56:03 GMT
Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
X-Newsreader: Tin 1.1 PL4

ark@alice.att.com (Andrew Koenig) writes:
: 
: About the strongest argument I can find *against* this so far is that
: C++ already inherits from C the unfortunate notion that undeclared variables
: are of type int. [...]
: 
: 	void foo() {
: 		auto x = 3.5;	// x would be type double
: 		auto y = x;	// ditto y
: 		auto n = 70000;	// n would be int or long,
: 				// depending on the machine
: 	}
: 
: But we can't do this because C already requires x, y, and n to be int in
: the declarations above and I don't think we can get away with breaking
: C compatibility here.

Why not?

During a phase-out period, such expressions where the type would be
"int" in C, but is different in C++, could generate warnings, and
later become errors.

The same applies if the "default int" rule is simply removed.  Warnings
for a while, then errors.  Good compilers may have switches to enable
compilation of the then obsolete code.

-- 
--------------------------------------------------------------------------
| 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: shang@corp.mot.com (David (Lujun) Shang)
Subject: Re: constructors & sizeof in C++
Reply-To: shang@corp.mot.com
Organization: Motorola, Inc., Software Research and Development, Rolling Meadows, IL. 60008
Date: Tue, 6 Oct 92 14:52:03 GMT


Let me answer the following questions from a differernt point of view.

In article <wL06TB1w165w@csource.oz.au> david@csource.oz.au (david nugent)  
writes:
> 
> Is this sort of constructur legal/advisable?
>  ...
>  Foo::Foo (void)
>  {
> 
>      memset (this, 0, sizeof(Foo));          // Or bzero()
>      .
>      .
>  }
> 
> 
> Is sizeof(Foo) guaranteed to be the size of the structure containing the
> declared object's non-static data? 

Yes, it could be, if the semantics of "sizeof" is improved in C++.

> Does the result of sizeof() change
> if there are any virtual functions in a base class?  

No, if we do not tag object code with vtable pointer in implementation.

> Or is it 'safer'
> to declare a structure to contain the members to initialse, and just
> memset/bzero those?
>

It could be safe to memset/bzero a class structure if we do not tag 
object code.
 
However, you'll get the opposite answer from the current C++.

David Shang

Newsgroups: comp.lang.c++
From: skdutta@ucs.att.com (Saumen Dutta)
Subject: gcc 2.2.2 feature/Bug?!
Organization: AT&T Universal Card Services, Jacksonville FL
Date: Wed, 7 Oct 1992 01:36:00 GMT

The following program gives a bus error when compiled with gcc-2.2.2 on
sparc station. It however runs without any problems with ATT C++. Can 
somebody confirm whether my installation of gcc is correct!

Thanks
skdutta



-----------------

class coord{
 public:
    double ctm[6]; 
    coord();
};

//--------------------------------------------------------

class xdisp{
  
public:
  xdisp();
};

//------------------------------------------------------------

class xwin: virtual public xdisp, virtual public coord{

public:
  xwin();

};

//----------------------------------------------------------



main()
{
        xwin tryme;
}


xwin::xwin():xdisp(), coord()
{

}


xdisp::xdisp()
{
}


coord::coord(){
        ctm[0] = (double)1.0;
        ctm[1] = ctm[2] = (double)0.0;
        ctm[4] = (double)1.0;
        ctm[5] = (double)0.0;
} 


Newsgroups: comp.lang.c++
From: lrn@watson.ibm.com (Lee R. Nackman)
Subject: Re: declare keyword, type inference
Date: Sun, 04 Oct 1992 23:13:18 GMT
Distribution: all
Disclaimer: This posting represents the poster's views, not necessarily those of IBM
Organization: IBM T.J. Watson Research Center

In article <23797@alice.att.com>, ark@alice.att.com (Andrew Koenig) writes:
|> In article <TMB.92Oct4201915@arolla.idiap.ch> tmb@idiap.ch writes:
|> 
|> > 	template <class T> typedef Array<Array<T> > Foo;
|> 
|> Does this buy anything over
|> 
|> 	template <class T> class Foo: public Array<Array<T> > { }
|> 
|> ?
|> -- 
|> 				--Andrew Koenig
|> 				  ark@europa.att.com

Yes.  Foo won't have any constructors or operator=() that Array<T> has.

Lee Nackman
From: Pete.Becker@mailbox.bison.mb.ca (Pete Becker)
Newsgroups: comp.lang.c++
Subject: Re: Help needed with BC++ DoubleList
Date: 25 Sep 92 07:21:40 GMT

Organization: Borland International

In article <20471@plains.NoDak.edu> cooper@plains.NoDak.edu (Jeff Cooper) writes:
>
>    DoubleList t();
>    ...
>    String *s1 = new String("One");
>    ...
>    t.addAtTail(*s1);
>     ^error occurs there

	't' is a function taking no parameters and returning a DoubleList.
Don't feel bad: everyone stumbles over this one a time or two...
	-- Pete

 * Origin: The Electronic Mailbox (1:348/7.0)
Newsgroups: comp.lang.c++,alt.msdos.programmer,comp.msdos.programmer
From: add@newshub.sdsu.edu (James D. Murray)
Subject: Borland's BGI driver flakey with Trident VGA chipset?
Organization: San Diego State University, College of Sciences
Date: Wed, 30 Sep 1992 22:20:06 GMT


I have been experiencing problems using an Everex Viewpoint VGA card
(16-bit, 256K, Trident chipset) with both the Zinc and Mewel windowing
systems in graphics mode (640x480) under the Borland BGI graphics driver
(EGAVGA.BGI).  The most severe problem is total machine lock-up when
exiting my application and the driver terminates.

I do not experience these problem when using VGA cards based on other
chipsets.  Is there a known bug(s) with the BGI driver and the Trident
chipset?  I can't seem to find any mention of this on CIS or USENET and
I haven't been able to get through to Borland technical support yet.

Thanks.

-- 
James D. Murray
add@sciences.sdsu.edu