HDTenEightyP/NetNews huggingface dataset:
From: adk@Warren.MENTORG.COM (Ajay Kamdar)
Subject: Re: can I 'delete' without a 'new'?
Organization: Mentor Graphics Corp. - IC Group
Date: Mon, 7 Sep 1992 18:20:55 GMT

In article <1992Sep4.171020.4762@kentrox.uucp> peter@kentrox.uucp (Peter Uchytil) writes:
>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 );
>}
>
    You have a severe bug in the above code. When you new a character array
    to hold a copy of the inString, you want to allocate space for ONE MORE
    than the length of the string (to hold the terminating '\0'). i.e.,
	String = new char[strlen(inString) + 1+;
	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?
>

    Yes, a real good way to frazzle the system. What you want to do is
    to set String to 0 in the default constructor as follows:

	foo::foo() : String(0) {}

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

     Yes, you need to do a delete before doing a new in set().


- Ajay

-- 
I speak for none but myself.

Ajay Kamdar                               Email : ajay_kamdar@mentorg.com
Mentor Graphics, IC Group (Warren, NJ)    Phone : (908) 580-0102
From: bs@alice.att.com (Bjarne Stroustrup)
Newsgroups: comp.lang.c++
Subject: Re: backwards references in templates
Date: 8 Sep 92 12:32:47 GMT
Distribution: comp
Organization: AT&T Bell Laboratories, Murray Hill NJ



tmb@arolla.idiap.ch (Thomas M. Breuel @ IDIAP) writes

 > The following definition of Foo appears to be illegal (GNU C++ doesn't
 > accept it, and the ARM doesn't seem to sanction it):
 > 
 > 	template <class K,K x>
 > 	struct Foo {
 > 		K y;
 > 		Foo() { y = x; }
 > 	};
 > 	
 > This restriction on the uses of template arguments (as in "Foo") is a
 > serious problem, since such dependencies occur frequently.

I see nothing wrong with this example and see nothing in the ARM that
prohibits it.
Newsgroups: comp.lang.c++
From: Adi Sumantri
Subject: Add me on the list
Organization: Prodigy Technologies Corp
Date: Fri, 4 Sep 1992 17:09:54 GMT

Please add me  
"sumantri@prodigy.bc.ca" 
Newsgroups: comp.lang.c++
From: cs911461@ariel.yorku.ca (CHRISTIAN D. ARMOUR)
Subject: GOTO's et al.
Organization: York University, Toronto, Canada
Distribution: all
Date: Sat, 5 Sep 1992 19:58:35 GMT

Hello all,

Though I'm only an insignificant little voice without a tremendous
cult following, I can't resist opening my mouth when it comes to 
goto's.  Then I shut up and wait till a Pascal vs. C debate occurs.

So then, for all you goto fans: why don't you just write in assembly?
At least you'll get blazing speed and a fabulous excuse.  Otherwise,
I can't understand why you'd want to use the ugly things; structured
programming pretty much abolished them just as OOP is pretty good
at eliminating the ugly "if(), else if(), else" business.

Basically, goto's and if's aren't aesthetically pleasing.  Sometimes,
you can tell a lot about something by the impression it leaves on the
subconscious.  Goto's make my unconscious go "ugh!".  I guess you
should use the proper tool properly to properly do the proper job.


Just my silly opinion,

C. Armour-Kidson
cs911461@ariel.yorku.ca
From: ark@alice.att.com (Andrew Koenig)
Newsgroups: comp.lang.c++
Subject: Re: zero-length datatype
Date: 12 Sep 92 15:51:36 GMT
Reply-To: ark@alice.UUCP ()
Distribution: comp
Organization: AT&T Bell Laboratories, Murray Hill NJ

In article <TMB.92Sep11211332@arolla.idiap.ch> tmb@idiap.ch writes:

> To remain compatible with C, you can interpret the above prototype as
> meaning either "a function taking no arguments" or as "a function
> taking exactly one argument of type 'void'". That is, it would be
> legal to call the above function as "f()" or "f(void())". Since there
> is no actual data being passed and no actual dereferencing happening,
> this is harmless.

No it's not harmless.  For example, consider overloading:

	extern void f();
	extern void f(T);

If T happens to be void, is this just a redeclaration of the same f?
I'm presuming that I want to be able to define f without knowing the
identity of type T.
-- 
				--Andrew Koenig
				  ark@europa.att.com
From: rjf@thunder.Berkeley.EDU (Russell Fleming)
Newsgroups: comp.lang.c++
Subject: Re: pointer typecasting question...
Date: 11 Sep 92 15:34:30 GMT

In article <1992Sep10.210319.4450@news.columbia.edu>,
kps@cunixb.cc.columbia.edu (Karthik P Sheka) writes:
> I'm working on a C++ program that is using a C package that is giving
> problems (The package was not meant to be used in C++):
> 
> One C call I make, CreateButton, takes as an arguement, a pointer to a
> function that takes one arguement and returns void:

	... C example deleted ...

> When used in a C++ program, I want to send a pointer to an instance of a
> public function.  Unfortunately, this does not work:
> 
	... C++ example deleted ...

This is a FAQ.  Each function of a class (except for static functions)
has an implied first argument which is a pointer to an instance of the
object.  Therefore, a function of a class which has a single int
argument is really a function which has two arguments (a pointer to the
object and an int).  A stand-alone function which has a single int
argument only has the single int argument.

=================================================================
Rusty Fleming, Software Consultant @ Tandem Computers Inc.
email: rjf@mpd.tandem.com            Austin, Texas
voice: (512) 244 - 8390              USA
Newsgroups: comp.lang.c++
From: bill@dewey.edsci.wisc.edu (Bill Roth)
Subject: Novice Question on Wierd class definition
Reply-To: bill@dewey.edsci.wisc.edu
Organization: Physical Sciences Lab, UW-Madison
Date: Thu, 10 Sep 92 16:09:26 GMT


I have been looking at a piece of code that looks something like  
this:

class A {
.. some defs...
}

class B(type) {
	type** C;
.more defs...
}


Is B a template class, or what its it? Is it an anachronism?


Please e-mail your replies.

Bill Roth
From: rons@hardy.u.washington.edu (Ronald Schoenberg)
Newsgroups: comp.lang.c++
Subject: Re: Proposal: Subscripting with multiple arguments
Date: 15 Sep 92 03:11:11 GMT
Organization: University of Washington, Seattle

In article <MATT.92Sep14161955@physics.berkeley.edu> matt@physics.berkeley.edu writes:
[..elided material...]
>
>What I find to be a bigger problem, actually, is designing an array
>class that works for arrays with an arbitrary number of dimensions.
>There's no problem with defining the classes Array1, Array2,
>Array3,..., and that's exactly what I've done, but it's annoying and
>inelegant.  Has anyone out there come up with a good definition for
>arrays with an arbitrary number of dimensions? ("Good," in this
>context, means specifically that array reference is sufficiently well
>optimized that an intelligent programmer wouldn't mind using this
>class in an inner loop.)
>--
>Matthew Austern                   Just keep yelling until you attract a
>(510) 644-2618                    crowd, then a constituency, a movement, a
>austern@lbl.bitnet                faction, an army!  If you don't have any
>matt@physics.berkeley.edu         solutions, become a part of the problem!

M++ has four dimensional arrays that can be generalized to any number
of dimensions with minor changes in source code.  It, however, overloads
operator() rather than operator[].  I am new to C/C++ and I am used to
using parens so I'm happy - I find typing [1][2][3] a lot harder than
(1,2,3).  I've been told by the designer of M++ that overloading
operator[] creates too many problems.
Newsgroups: comp.lang.c++
From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
Subject: Re: GOTO, was: Tiny proposal for na
Organization: Texas Instruments Inc
Date: Fri, 11 Sep 1992 18:37:34 GMT

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

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

>|Now if only the rest of your notes reflected that use of the word
>|'guide', rather than treating structured programming as if it was
>|carved on stone tablets and handed down from the mountain.

>I have repeatedly stated that physical need outweighs design
>principles.  If you must use gotos, or global variables, or any of the
>other evils of software, in order to fulfill the requirements, then
>do so, and without hesitation.

But you are talking only about timing constraints.  As I and others
have said repeatedly, there are other reasons to use gotos, multiple
returns, breaks, etc.

-- 
"Insisting on perfect safety is for people who don't have the balls to live
 in the real world."   -- Mary Shafer, NASA Ames Dryden
------------------------------------------------------------------------------
Fred.McCall@dseg.ti.com - I don't speak for others and they don't speak for me.
From: schrod@iti.informatik.th-darmstadt.de (Joachim Schrod)
Newsgroups: comp.lang.c++
Subject: Re: More on C++ yacc grammar
Date: 14 Sep 92 17:15:11 GMT
Organization: TU Darmstadt

In article <BuHutx.z6@well.sf.ca.us>, johnrp@well.sf.ca.us (John Panzer) writes:
> 
> I'm interested in finding a Yacc-able C++ grammar as well - even a
> partial grammar would be useful to me.  However, the archie server
> doesn't seem to know about C++ grammars (only C grammars show up
> on my searches).  Also, an earlier posting about an anonymous ftp
> site was incorrect - there ain't no grammars there!

Try

	ftp.th-darmstadt.de [130.83.55.75]
	directory
	pub/programming/languages/C++/tools
	file c++grammar2.0.tar.Z

Btw, xarchie tells me: ``Found 27 matches'' Perhaps you might want to
take one site in the US, eg, ics.uci.edu:/gnu/c++grammar2.0.tar.Z

--
Joachim

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Joachim Schrod			Email: schrod@iti.informatik.th-darmstadt.de
Computer Science Department
Technical University of Darmstadt, Germany
From: holland@dutiws.tudelft.nl (Gerhard den Hollander)
Newsgroups: comp.lang.c++
Subject: Simple question, sages advice needed
Date: 14 Sep 92 14:45:42 GMT
Organization: Delft University of Technology

Hi,
I have the following (rather simple and stupid) problem.
 
I have a Class A, with a member name (of type MyString).
MyString is just what you'd expect of it,
and contains a friend function operator<<(...);
 
I am currently working with yacc/bizon,
and the following happens.
 
[Note, yacc passes a A* via it's $$ mechanism]
 
Yacc-file (stripped a lot)
 
start : flip flap flop
      {
        cout << *$2 << " Top" << endl;
      }
  
flap  : e f g
      {
         $$ = new A(*$2);
      }
      
f     : e A_POINTER g
      {
        $$ = new A(*$2);
        cout << *$2 << " Bottom" << endl;
      }
      
 
Well after compiling and running this gives
Some.value Bottom
Top
 
My question is,
what happened, why doesn't it say Some.value Bottom
Some.value Top ?
 
Anyone having ideas ??

(Oh BTW cout << *$2 is the same as cout << $2->name )
 
Thanks
please reply via email,
I'll gather answers and post a summary

Newsgroups: comp.lang.c++
From: taf@firewalladaclabs.com (Tom Fitzgerald)
Subject: InterViews vs OI
Keywords: GUI,InterViews,OI
Organization: Adac Labratories, Milpitas Ca
Date: Fri, 4 Sep 1992 22:24:09 GMT

Has anyone done a comparison of InterViews and Solbourne OI (in
its various manifestations).  We are considering using one of
them and would like to know what peoples experiences are.

Thanks,

Tom Fitzgerald
-- 
*****************************************************************

Tom Fitzgerald			Internet: taf@adaclabs.com
ADAC Labs		        Phone:    (408) 321-9100 ext 1727

******************************************************************
Newsgroups: comp.lang.c++
From: pjl@sparc10.cs.uiuc.edu (Paul Lucas)
Subject: Re: Problems with constructor in C++
Organization: University of Illinois at Urbana-Champaign
Distribution: na
Date: Tue, 15 Sep 1992 03:07:05 GMT

In <1992Sep14.225041.15692@access.usask.ca> srikant@skorpio.usask.ca (Srikant Subramaniam) writes:

>Hello Netters:

>I have a rather peculiar problem with constructors in C++. In the code
>fragment below, the constructor for AtomicInt is not executed at all.

>File chore.h
>------------

>Class Chore : public DLINK {

>	......
>	.......

>	AtomicInt numworkers;
>public: Chore ( .......) {
>	
>	}
>} // Class Chore

>File atomic_int.h
>------------------

>Class AtomicInt {

>	...........

>	AtomicInt() { .......}
>	AtomicInt(int x) { ......}
>	AtomicInt(AtomicInt& x) { .......}
>}

>When the code is executed, the constructor for AtomicInt doesn't get executed
>at all. My understanding of C++ was that when the initialization is done as
>in AtomicInt numworkers, the constructor is automatically executed. I hope I'm
>not wrong :-(

>Could somebody out in net.land  clarify this ?

*****>	You are correct.  The default constructor will (should) be called.
	(BTW, I assume you meant "class" not "Class"?)  Why doesn't it
	work then....don't know.
-- 
	- Paul J. Lucas				University of Illinois	
	  AT&T Bell Laboratories		at Urbana-Champaign
	  Naperville, IL			pjl@cs.uiuc.edu
Newsgroups: comp.lang.c++
From: dave@soil.gsfc.nasa.gov (David Graham)
Subject: Looking for Image Processing Classes
Keywords: image processing, classes
Reply-To: dave@soil.gsfc.nasa.gov (David Graham)
Organization: NASA/GSFC code 923
Date: Fri, 11 Sep 1992 21:15:22 GMT

I have just taken a short OOD C++ class and build g++ on the system
here.  Now I would like to try out some programming in our image
processing environment.  Rather than reinventing the wheel, I was
wondering if anyone had some image processing classes which I
could get for FREE.  If I cannot find that I would also be interested
in a Matrix class ( which I could use to store images).
--
_____________________________________________________________________
|                                      |                            |
|             /\W_W/\                  | David W. Graham            |
|          __/  0 0  \__               | Code 923.0                 |
|         __<\       />_\              | NASA/GSFC                  |
|        / <\  \___/  />               | Greenbelt, MD 20771        |
|         <     _|_     >              |                            |
|        <     /   \     >             | Voice: (301) 286-3799      |
|       < __          __ >             |                            |
|______<_/  _________/  _>_____________| Internet:                  |
|        UUU         UUU               |    dave@soil.gsfc.nasa.gov |
|                                      |                            |
|  Everyone's entitled to my opinion.  |                            |
+-------------------------------------------------------------------+
Newsgroups: comp.lang.c++
From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
Subject: Re: GOTO, was: Tiny proposal for named loops.
Organization: Texas Instruments Inc
Date: Fri, 11 Sep 1992 18:42:07 GMT

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

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

And just how, pray tell, do you recover from an error WITHOUT coupling
between the error condition and the error processing, since what error
processing you need to do is most certainly going to be dependent on
what your error condition is?

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

So instead you do WHAT?  I don't see any better solution, other than
duplicating huge blocks of code to do error handling at each test on
the way through the code (in the other arm of the 'if').  If you are
also following another one of those guides that often becomes a goal
in itself (function size limits) you rapidly reach the point (with all
that duplicated code for error handling) where you can no longer even
write the function.  There's another one of those rules (depth of
nesting) that will 'kill' your method, as well.

-- 
"Insisting on perfect safety is for people who don't have the balls to live
 in the real world."   -- Mary Shafer, NASA Ames Dryden
------------------------------------------------------------------------------
Fred.McCall@dseg.ti.com - I don't speak for others and they don't speak for me.
Newsgroups: comp.lang.c++
From: nikki@trmphrst.demon.co.uk (Nikki Locke)
ReplyTo: nikki@trmphrst.demon.co.uk
Subject: Re: help
Distribution: world
X-Mailer: cppnews $Revision: 1.16 $
Organization: Trumphurst Ltd.
Date: Tue, 15 Sep 1992 11:27:18 +0000


In article <1992Sep13.164046.24676@njitgw.njit.edu> jxd7299@hertz.njit.edu (Jing X Ding) writes:

> 
> 	PROD *A;//PROD is a defined class
> 	   :
> 	   :
> 	for (...){
> 	A=(PROD*)new char [totalprod*sizeof(PROD)];//totalprod is a const
> 	   :
> 	   :
> 	 Place 1
> 	}
> 	 Place 2
> 
> The problem is :(1) Where can I use destructure to free memory (Place 1 or
> Place 2)? (2) How to write the destructure?
That is an interesting corruption of the word "destructor" - meaningful, 
too !

What you want is ...
A = new PROD[totalprod];
    :
    :
delete [] A;

---
Nikki Locke              |                        | nikki@trmphrst.demon.co.uk
Trumphurst Ltd.          | Tel: +44 (0)691-670318 | nikki@cix.compulink.co.uk
PC and Unix consultancy  | Fax: +44 (0)691-670316 | nikki@kewill.co.uk
trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
Demon.co.uk is a dial-up subscription access point to the Internet.
From: fellin@sumax.seattleu.edu (Phillip Fellin)
Newsgroups: comp.lang.c++
Subject: XVT second try.
Keywords: XVT
Date: 9 Sep 92 02:37:30 GMT
Organization: Seattle University, Seattle, WA

We are evaluating the XVT Portability tool kit
for cross platform development in c++.  Does 
anyone out there have any experience or comments?
We heard some standards committee was considering
XVT as their standard, anybody else hear this rumor?
Finally, has anyone used the Borland OWL for Windows
and OS/2 cross platform dev?  Oh and also, does 
anyone know if Borland will extend their language
products to include X & Mac?
thanks!!

Newsgroups: comp.lang.c++
From: edy@andersen.com (Edy Liongosari)
Subject: cpp/cfront program size limitation
Organization: Andersen Consulting
Date: Wed, 9 Sep 1992 20:17:12 GMT


I am using cfront 2.x in a Sun Sparc to compile about 45,000 lines
of C++ program. The resulting C code has invalid line numbers
after line (+/-) 32000.
It seems to me the variable to store the line number is of type "short" 
integer. Can any body confirm or deny this?
If so, do you know any way to fix this from cpp/cfront side?

I know that I can break to program into several smaller pieces. I am looking
for other solutions.

Thank you.

-Edy

PS: FYI, the 45,000 line program is generated by a tool and not by human.
    I am trying to find a quick fix to the problem since we do not have
    the source code of the tool that generates the program.
    I guess, I can write a post-processor to slit the resulting program
    into smaller pieces.

    Any advice?
    

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

Edy S. Liongosari                                E-mail: edy@andersen.com
Center for Strategic Technology Research            Phone: (312) 507-8482
Andersen Consulting                                   Fax: (312) 507-3526
From: dlabonte@dciem.dciem.dnd.ca (Daniel Labonte)
Newsgroups: comp.lang.c++
Subject: Serial port access
Date: 8 Sep 92 21:08:45 GMT
Distribution: ont
Organization: Defence and Civil Institute of Environmental Medicine

I am writing some code to interface a device connected to a
serial port at a transfer rate of 19200 bauds. 

The problem is that the documentation I have on serial ports indicates
that the maximum transfer rate is 9600 baud (PC intern from Abacus).
This is done by setting bits 5-7 of the AL register.

Can someone tell me how to set the baud rate to 19200 ?  
Is the AL register redefined so that the new definition (ie bit 5-7 
set high) corresponds to 19200 baud transfer rate ?

Thanks in advance
dlabonte@dretor.dciem.dnd.ca
From: schrod@iti.informatik.th-darmstadt.de (Joachim Schrod)
Newsgroups: comp.lang.c++
Subject: Re: Looking for a semaphore class specification/implementation
Date: 14 Sep 92 17:09:48 GMT
Distribution: usa
Organization: TU Darmstadt

In article <1992Sep10.172206.20949@cellnet.com>, ashok@cellnet.com (Ashok Bakthavathsalam) writes:
> The subject says it all...
> 

You did not mention your environment. But anyhow, try

	ftp.th-darmstadt.de [130.83.55.75]
	directory pub/programming/languages/C++/class-libraries/misc
	file semaphore.tar.Z

I append the README below.

--
Joachim

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Joachim Schrod			Email: schrod@iti.informatik.th-darmstadt.de
Computer Science Department
Technical University of Darmstadt, Germany


---------------- included file follows: semaphore.README
No warranty, No copyright, No price, No nothing!

Semaphore class library - SYSV semapahore class implementation. The race
-----------------------   conditions has been taken care of by following
examples from the "UNIX Network programming" by Stevens. Semaphores are
created by using an unique key. Individual semaphores are referred by
using square bracket operator as in arrays. Incrementing and decrementing 
semaphores can be done using the operators ++ and --. Please see the example
in file test.C. You should be able to run it in two different processes.

Developed using SUN-OS 4.1 and AT&T 2.0 c++. May not work as is in other
platforms.

All comments welcome!! send them to skdutta@cs.tamu.edu


Have fun
skdutta
Newsgroups: comp.lang.c++