HDTenEightyP/NetNews huggingface dataset:
From: steve@taumet.com (Steve Clamage)
Subject: Re: Creating arrays of a class object using default constructor
Organization: TauMetric Corporation
Date: Tue, 8 Sep 1992 16:48:41 GMT

scsr91@csc.liv.ac.uk (Mr. J.A. Coyne) writes:

>class compound  {
>   basic * array; // pointer to class basic
>public:
>   compound(); // class constructor function
>};

>compound::compound()  { array = new basic[10]; }

>class basic {
>    int * vector;
>public:
>      basic(int =5) ;
>};

>basic::basic(int size)  { vector = new int[size]; }

>The error message I recieve is  : default arguments for constructor for array
>of class basic(2005)

This is an area where the language has changed.  An array of objects
with a constructor require the "default constructor".  It used to be
that the "default constructor" was one which had no parameters, and a
constructor with all parameters defaulted was not a substitute.  The
newer language rule is that the "default constructor" is one which
does not require arguments, meaning that your code is now legal.

The cfront 2.1 compiler followed the old rule.  A workaround is to
make two constructors:

    basic()	    { vector = new int[5]; }
    basic(int size) { vector = new int[size]; }
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Vice Chair, ANSI C++ Committee, X3J16
Newsgroups: comp.lang.c++
From: kanze@us-es.sel.de (James Kanze)
Subject: Re: GOTO, was: Tiny proposal for na
Organization: SEL-Alcatel LTS Dept. US/ES
Date: Mon, 31 Aug 92 17:09:08 GMT

In article <rmartin.715102882@thor>, rmartin@thor.Rational.COM (Bob Martin) writes:
|> hosken@spss.com (Bill Hosken) writes:
    [...]
|> >A better rule would be "Be prepared to give a clear and convincing
|> >argument that the code is correct". 
|> 
|> But what is "correct code"?  Code that works?  I can write code that
|> works, but is unmaintainable.  If all we want to produce is "code that
|> works", then the nightmares which have plagued us from the late
|> sixties on are sure to continue.

Bob, don't you realize that Bill has just given the strongest argument yet
in favor of what you've been saying.  The only "clear and convincing argument
that the code is correct" must use logical proof of correctness concepts.
These concepts, at least in the literature I've seen, *only* address the three
basic forms of program flow: sequence, iteration and conditional.  In particular,
to reason about program correctness, it is essential that each program block
have one and only one point of entry and one and only one point of exit.

This means that you can use a goto, as long as it does exactly what a while,
an if...else or a switch would do.  I can't see why you would want to in C,
though, since it *does* have these structures.  (One of the best structured
programs I ever saw was written in Fortran-66, and it was full of goto's.
However, every one was used to mimic one of the above structures, none of
which existed in the language.)

On the other hand, you *cannot* use break or continue, since these mimic a
goto to somewhere you *do not* what to go to.  In the same way, how do you
prove a function correct if it returns somewhere from the middle.

Apparently most of the responses have been in favor of using break.  Do I
conclude that most programmers just don't care about having correct programs?
--
James Kanze                            GABI Software, Sarl.
email: kanze@us-es.sel.de              8 rue du Faisan
                                       67000 Strasbourg
                                       France
Newsgroups: comp.lang.c++
From: shang@corp.mot.com (David (Lujun) Shang)
Subject: Re: zero-length datatype
Reply-To: shang@corp.mot.com
Organization: Motorola, Inc., Software Research and Development, Rolling Meadows, IL. 60008
Distribution: comp
Date: Mon, 14 Sep 92 13:32:24 GMT

In article <TMB.92Sep12212544@arolla.idiap.ch> tmb@arolla.idiap.ch (Thomas M.  
Breuel) writes:
> In article <23654@alice.att.com> ark@alice.att.com (Andrew Koenig) writes:
> 
>    In article <1992Sep10.181836.9929@cadsun.corp.mot.com> shang@corp.mot.com  
writes:
> 
>    > Note that C g++ implements empty struct or class with size of zero. 
>    > g++ also allows an array with zero number of member with size of zero.
> 
>    Unfortunately, this violates the ISO C standard, which explicitly says
>    that there are no zero-size objects.
> 
> I think Shang's claim is false. GNU C++ 2.2.2 reserves at least 1 byte
> for the empty structure.
> 

The GNU C++ installed on my computer says that "sizeof(EmptyStruct)==0". It's a  
version lower that 2.2.2 of cause.

Newsgroups: comp.lang.c++,gnu.g++
From: steve@taumet.com (Steve Clamage)
Subject: Re: Variable Declarations
Keywords: variables, constructors
Organization: TauMetric Corporation
Date: Thu, 10 Sep 1992 17:09:48 GMT

u895217@bruny.cc.utas.edu.au (Scott Marshall) writes:

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

|	char buf[whatever];
|	f.getline(buf, whatever);
|	while (buf[0] != '#') {
|		String s = buf;
|		if (s.contains("int") ...
|		else ...
|		f.getline(buf, whatever); }

Local object 's' will be newly constructed at the top of the loop
for each iteration, and destroyed at the bottom of the loop.  The
braces make a new scope and ensure these semantics.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Vice Chair, ANSI C++ Committee, X3J16
From: mhr@hitkw18.pki-nbg.philips.de (Muharem Hrnjadovic)
Newsgroups: comp.lang.c++
Subject: Re: Reference to a pointer??
Keywords: pointer, reference
Date: 11 Sep 92 13:31:49 GMT

ucosmo@mcl.ucsb.edu (Boris Burtin) writes:

>I have not been able to dig up any information on how to change a pointer 
>inside a function (aside from the good old dual-pointer C solution).  ...

	.
	.
	.

>So why can't you do this:

>void f(int& *p)
>{
>	p = 0;
>}

It should be the other way round :

	void f(int *& p)
	{
		p = 0;
	}

now f() receives a reference to a pointer as its argument.

Regards,


  -- Muharem
From: rmartin@thor.Rational.COM (Bob Martin)
Newsgroups: comp.lang.c++
Subject: Re: Avoiding returning references to Temporaries
Date: 7 Sep 92 12:47:33 GMT

coller@alnitak.usc.edu (Lee D. Coller) writes:
[...]

|The idea is that the member function D::getA() would be able to construct a
|B or C and return it to the caller as an A.  Because of the semantics, most
|likely D::getA() will have to create a temporary, so just returning a
|reference to some pre-existing B or C will not work.

[...]

|The best solution I could come up with is to create another class to handle
|managing a pointer to A such as the following.

[...example removed...]

|My question is, I would like to be able to do this without having A handle
|reference counting.  Can anyone think of a good method?  Am I overlooking
|some simple, elegant solution?  Also, is this what is referred to as a
|"Smart pointer class?"

Take a look at "Advanced C++ Programming Styles and Idioms" by James
O. Coplien in the section entitled "Envelope Classes and Delegated
Polymorphism".  Here he talks about your problem and provides a
solution.

The idea is to provide class A with a A* member, and a member
functions that can determine whether a B or C is needed.  The needed
class is placed in the A* pointer of the A object.  All other method
calls of the A objects are explicitly deferred to the A* object.

For example:

class A
{
  public:
     A() {itsA = 0;}
     A(some criteria)
     {
       if (some criterion)
         itsA = new B(...);
       else
         itsA = new C(...);
     }

     virtual ~A() {delete itsA;}

     virtual int DoSomething(int x) {return itsA->DoSomething(x);}

  private:
     A* itsA;
};

class B : public A { public: B(); int DoSomething(int);};
class C : public A { public: C(); int DoSomething(int);};

Now, whenever you construct an A object, whether from the heap, or on
the stack, or even statically; if you supply a criterion, the
appropriate B or C will be silently constructed and saved by the A
object.  When you invoke the methods of A (DoSomething), those methods
are simply deferred to the saved B or C object.  When the A object is
destructed, the B or C is also automatically destroyed.

This method works well, but has one glaring fault.  A must know about
B and C.  If more derivatives of A are needed later, A must change to
support them in its constructor.  

--
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: rmartin@thor.Rational.COM (Bob Martin)
Newsgroups: comp.lang.c++
Subject: Re: Pointer or Reference Arguments
Date: 7 Sep 92 13:06:25 GMT

KOCHER@141.58.123.1 (HARTMUT KOCHER) writes:

|I am currently trying to find a consistent style in 
|using pointer and references as function arguments.
|Currently, I am thinking about two different styles that 
|I want to explain in the following paragraphs:

|1) Reference arguments are used only when aliasing 
|occurs and the parameter is used only during the 
|lifetime of the function. Pointers are used whenever the 
|function might keep a copy of the pointer for later use, 
|e.g., store it in a private list.

|2) Reference arguments are used whenever you must supply 
|a valid object to the function. Pointers are used when 0 
|might be a valid parameter as well.

I use style 2) exclusively.  I use a reference parameter to indicate
to the caller that I expect a valid object, and that i am not going to
test it for zero.  I use a pointer argument if the argument can be
zero, (works well with default arugments)

The same goes for return values and elements in structures.  If they
are pointers, they can be zero and must be tested.  If they are
refereces, my convention says that they must exist, and need not be
tested for zero.

In C++ a zero reference is illegal, (Although many compilers don't
check for it.)  And a reference in a structure or class must be bound
at initialization.  So the guarantee that a reference indicates that
an object is present is a reasonable one.

My objection to style 1) is that it must compete with zero pointers.
i.e. an argument which qualifies as a reference under fule 1) might
still have to be a pointer if it can be zero...


--
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: pjl@sparc10.cs.uiuc.edu (Paul Lucas)
Subject: Re: A question about "const".
Organization: University of Illinois at Urbana-Champaign
Distribution: usa
Date: Tue, 15 Sep 1992 02:56:09 GMT

In <193h6dINN2of@miles.mps.ohio-state.edu> ren@miles.mps.ohio-state.edu (Liming Ren) writes:

> Could somebody tell me what the role of const is in the following code?
>I am new to C++. 


>class	String{
>public:
>	int length() const {return len;} //The const in between ) and {
>	//...
>private:
>	int len;
>	char *str;

>}

*****>	ARM, p.177 -or- Stroustrup, 2nd ed., p.148.
-- 
	- Paul J. Lucas				University of Illinois	
	  AT&T Bell Laboratories		at Urbana-Champaign
	  Naperville, IL			pjl@cs.uiuc.edu
Newsgroups: comp.lang.c++
From: ewh@emf780.den.mmc.com (Edward Householder)
Subject: Borland C++ 3.1 TDW hang w/ ATI Ultra - help?
Organization: Martin Marietta, Denver
Date: Wed, 9 Sep 1992 16:23:38 GMT


How do I get the Borland C++ 3.1 TDW (Turbo Debugger for Windows) to 
work with the ATI Ultra Graphics card?

There have been a few posts on the net concerning TDW hanging when
using The ATI Ultra Graphics card/drivers.

I have not been able to make TDW work.  

!!!
Would someone kindly post or email the exact solution?
!!!

My configuration is:
Borland C++ 3.1
Gateway 486 DX2/50 
ATI Ultra Graphics Video Card
Windows 3.1

Thanks for your help, I will post a summary solution.

____________
ed householder
email:  ewh@emf780.den.mmc.com
...........................................................the end!
Newsgroups: comp.lang.c++
From: pjl@sparc10.cs.uiuc.edu (Paul Lucas)
Subject: Re: help
Organization: University of Illinois at Urbana-Champaign
Distribution: usa
Date: Mon, 14 Sep 1992 02:27:15 GMT

In <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?

*****>	new is not malloc; you don't calculate the size nor cast.

		for (...) {
			A = new PROD[ totalprod ];
			// ...
			delete[] A;
		}
	
	I suggest reading the relevant section on new/delete in a C++
	book.
-- 
	- Paul J. Lucas				University of Illinois	
	  AT&T Bell Laboratories		at Urbana-Champaign
	  Naperville, IL			pjl@cs.uiuc.edu
Newsgroups: comp.lang.c++
From: steve@taumet.com (Steve Clamage)
Subject: Re: defining cast operators outside classes
Organization: TauMetric Corporation
Date: Tue, 8 Sep 1992 17:36:13 GMT

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

>Apparently, it is impossible to define a conversion operator for a
>class without making the conversion operator a member function.

>It would be very useful to be able to define something like the
>following without having to modify either class MyMatrix or class
>TheirMatrix:

>	operator MyMatrix(TheirMatrix &m) {
>		...
>	}

>Why was this seemingly arbitrary restriction made? Can it be
>eliminated in the next version of C++?

In general, those operators which must be class members have that
restriction to reduce the chance of subtle but serious bugs.

Consider operator+().  If we write x+y, where x or y has a class
type, and no operator+ is visible, the code will not compile.  You
must make a declaration visible.  There is nothing subtle or
dangerous about this.

In the case of some operators you run the risk of having legal code
with different meanings depending on whether the operator declaration
is visible.  In the case of user-defined conversions, consider this:

class X {
    public:
	operator int();
};

X x;
double y = x;

extern operator double(const X&);	// not legal
double z = x;

In this case, y gets "(double) X::operator int(x)",
while z gets "operator double(x)".

The semantics depend on which non-class declarations are visible,
which is not normally the case in C++.  (There is a somewhat
parallel case:  You omit one overloaded function declaration and
an unintended function is called.  Maybe someone can think of a way
to solve that problem in the language.)

In the case of conversions, it is likely that the conversion function
would need to be a friend function, thus needing to appear in the
class definition anyway.

If you need to create an ad-hoc conversion from class A to class B
when you don't own class A, you can make a B constructor taking an A.
If you don't own class B either, you can write an ordinary function
which does the conversion.

In the end, the restriction elminates a source of dangerous but subtle
bugs while creating virtually no extra inconvenience.  The only
inconvenience I can see occurs when ALL of these are met simultaneously:
	- You need to convert an A to a B.
	- You can't modify A or B.
	- Everything needed to do the conversion is public.
	- You want implicit conversion, not "b = A_to_B(a)".
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Vice Chair, ANSI C++ Committee, X3J16
Newsgroups: comp.lang.c++
From: dave@soil.gsfc.nasa.gov (David Graham)
Subject: comp.lang.c++.src ?
Keywords: c++, source code
Reply-To: dave@soil.gsfc.nasa.gov (David Graham)
Organization: NASA/GSFC code 923
Date: Tue, 15 Sep 1992 18:20:29 GMT

In the promotion of software reusability how about a group
comp.lang.c++.src where people could:

Share objects.
Request objects.
Give information where to obtain objects.

Would there be any support?

--
_____________________________________________________________________
|                                      |                            |
|             /\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.  |                            |
+-------------------------------------------------------------------+
From: jxd7299@hertz.njit.edu (Jing X Ding)
Newsgroups: comp.lang.c++
Subject: help
Date: 4 Sep 92 16:50:10 GMT
Organization: New Jersey Institute of Technology, Newark, N.J.
  Class A {
   private:
    int var1;
    char* var2;
   public:
    A(int ovar1,char* ovar2) {
	var1 = ovar1;
        var2 = ovar2;
	printf("the value of var2:%s\n",var2);//The result of this stmt is OK
	}

Jing Ding(jxd7299@hertz.njit.edu)
Newsgroups: comp.lang.c++
From: pjl@sparc10.cs.uiuc.edu (Paul Lucas)
Subject: Re: Bogus warning message
Organization: University of Illinois at Urbana-Champaign
Date: Wed, 9 Sep 1992 14:47:36 GMT

In <3914@tivoli.UUCP> taylor@foraker.tivoli.com (Eric Taylor) writes:

>How do I stop gcc-2.2 from giving me the following message
>while still getting all of the others.  I can't seem to
>find any option to get rid of it.

>warning: dbx info for template class methods not yet supported

	dbx ... 2>&1 | fgrep -v 'info for template class methods not yet'
-- 
	- Paul J. Lucas				University of Illinois	
	  AT&T Bell Laboratories		at Urbana-Champaign
	  Naperville, IL			pjl@cs.uiuc.edu
Newsgroups: comp.lang.c++
From: nikki@trmphrst.demon.co.uk (Nikki Locke)
ReplyTo: nikki@trmphrst.demon.co.uk
Subject: Re: can I 'delete' without a 'new'?
Distribution: world
X-Mailer: cppnews $Revision: 1.15 $
Organization: Trumphurst Ltd.
Date: Mon, 7 Sep 1992 18:45:52 +0000


In article <1992Sep5.160932.19698@taumet.com> steve@taumet.com (Steve Clamage) writes:

> It is always harmless to
> delete a null pointer.
Except in some previous Zortech C++ versions, where calling delete for a 
pointer to a class with a virtual delete, with a value 0, crashed the 
machine. This is, of course, a bug - but one to look out for.
---
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.
Newsgroups: comp.lang.c++
From: feustel@netcom.com (David Feustel)
Subject: Need Pointers to Good Discussion of Persistant Objects
Date: Tue, 15 Sep 92 23:32:06 GMT
Organization: DAFCO: OS/2 Software Support & Consulting

I'm looking for solutions to the problem of persistance of objects
across multiple program invocations. Is there a good discussion of
this problem available? Thanks.
-- 
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.
Xref: sparky comp.lang.c++:13517 gnu.g++.help:1217
From: steve@taumet.com (Steve Clamage)
Newsgroups: comp.lang.c++,gnu.g++.help
Subject: Re: Variable Declarations
Keywords: variables, constructors
Date: 10 Sep 92 17:09:48 GMT
Followup-To: comp.lang.c++,gnu.g++.help
Organization: TauMetric Corporation
To: gnu-g++-announce@uunet.uu.net

u895217@bruny.cc.utas.edu.au (Scott Marshall) writes:

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

|	char buf[whatever];
|	f.getline(buf, whatever);
|	while (buf[0] != '#') {
|		String s = buf;
|		if (s.contains("int") ...
|		else ...
|		f.getline(buf, whatever); }

Local object 's' will be newly constructed at the top of the loop
for each iteration, and destroyed at the bottom of the loop.  The
braces make a new scope and ensure these semantics.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Vice Chair, ANSI C++ Committee, X3J16
From: allan@stasys.UUCP (Allan Brighton)
Newsgroups: comp.lang.c++
Subject: Info on USL Standard Components Class Library ?
Keywords: USL class library
Date: 13 Sep 92 18:57:42 GMT
Organization: Contract Software Engineer, Munich Germany


Hi all,

I'm trying to decide which general class library to use for a project.

How does the "USL Standard Components" class library compare with 
some of the "public domain" libraries like COOL, LEDA or NIHCL ?

Is the USL class library likely to become a standard for C++ - like libc for C ?

Can someone tell me where you can get the USL library (for Sun) and how
much it costs ?  

Is it available in source form ?  

Is it available for Sun/Solaris 2.0 ?

Thanks 

---

Allan Brighton






-- 

Allan Brighton
Newsgroups: comp.lang.c++
From: leo@sci.kun.nl (Leo Willems)
Subject: const * const return value
Summary: bad return value for const * const
Keywords: const pointer
Organization: University of Nijmegen, The Netherlands
Date: Mon, 7 Sep 1992 21:08:27 GMT


Is the returntype const char * const legal when it is assigned to a const char*:

const char * const
f()
{
	return "aa";
}

void
x()
{
	const char * p = f();   // legal assignment??

	++p;			// sigh
}

cfront 3.0.1 is accepting this, according to me it breaks the meaning
of a const pointer to const. Is there an explanation?

Please E-mail to leo@atcmp.nl

Thanks.


Leo

Newsgroups: comp.lang.c++
From: sdm@cs.brown.edu (Scott Meyers)
Subject: Re: inline virtual functions
Organization: Brown University Department of Computer Science
Date: Tue, 15 Sep 1992 18:54:43 GMT

I originally wrote:

| >I was involved in a discussion of this issue today when it was suggested
| >that compilers should generate only a single copy of an out-of-line virtual
| >function, and that the single translation unit in which the function
| >definition should be generated should be the same as the one containing the
| >class's vtbl.  This seems sensible to me, so I was wondering: is there some
| >reason why compiler implementers don't do this?

Mike Ball responded:

| No.  In general, that's what will happen.  Both cfront and our own compiler
| do exactly that in the case above.

My tests did not indicate that that was the case, but then Mike reminded me
that when *all* the virtual functions in a class are inline, the vtbl is
replicated in each translation unit.  (cfront offers compiler switches to
avoid this problem).  When I reexamined my test cases, I discovered that
I'd made all my virtual functions inline, hence the behavior I'd seen was
more pathological than typical.  In short, Mike is right and I was wrong,
at least as regards cfront.  (However, it still seems to be the case that
g++ generates a static copy of inline virtuals for every file that sees
their definition, but perhaps I've again overlooked something.)

I apologize for the misinformation I posted earlier.  Thanks to Mike Ball
for pointing out the error of my ways.

Scott








-------------------------------------------------------------------------------
What do you say to a convicted felon in Providence?  "Hello, Mr. Mayor."
From: ren@miles.mps.ohio-state.edu (Liming Ren)
Newsgroups: comp.lang.c++
Subject: A question about "const".
Date: 14 Sep 1992 22:18:53 -0400
Organization: Department of Mathematics, The Ohio State University
Distribution: usa
NNTP-Posting-Host: miles.mps.ohio-state.edu



 Could somebody tell me what the role of const is in the following code?
I am new to C++. 


class	String{
public:
	int length() const {return len;} //The const in between ) and {
	//...
private:
	int len;
	char *str;

}