HDTenEightyP/NetNews huggingface dataset:
From: robert@alkymi.unit.no (Robert Schmidt)
Subject: is 'this' obsolete??!!
Organization: Norwegian Institute of Technology
Date: Thu, 21 Jan 93 18:12:19 GMT


I recently heard someone mention that the use of 'this' is obsolete,
and that another method is preferred...  I've forgotton how, sorry.
I also found this claim in the on-line help of Borland C++ 3.1.

Can you elaborate on this?  What is the preferred method, if 'my sources'
are correct?

Please reply via e-mail, thanks!

robert@alkymi.unit.no
Newsgroups: comp.lang.c++
From: steve@taumet.com (Steve Clamage)
Subject: Re: operator = with inheritance
Organization: TauMetric Corporation
Date: Thu, 28 Jan 1993 18:48:36 GMT

pjcondi@ns.pacbell.com (Paul Condie) writes:

>class A {
>   public:
>	...
>	virtual A & operator = (const A & rhs) {
>		a = rhs.a;
>		return *this;
>	}
>   private:
>	int a;
>};


>class B : public A {
>   public:
>	...
>	A & operator = (const A & rhs) {
>		A::operator = (rhs);
>		// The following cast should be ok because we know
>		// we have a B object because the virtual mechanism
>		// has told us. right?
>		b = ((B &)rhs).b;
>		return *this;
>	}
>   private:
>	int b;
>};

The assumption in the comment is wrong.  Suppose we write
	A x;
	B y;
	...
	y = x;
We will get
	y.B::operator=(x);
The function assumes incorrectly that its argument is a B, but it is
really an A.

Secondly, an unrelated point.  It is not a very good idea to call A::op=
explicitly in B::op=, since a B member function now depends on the
details of the A class.  For example, the op= in A might be removed
on the grounds it does exactly what the default version would do.  The
B::op= function will no longer compile.

You usually want to invoke the base class op= implicitly, so that you
can get the compiler-generated version if that's all there is.  Here
is a schema for the op= of a derived class.

	B& B::operator=(const B& rhs) {
	    if( this != &rhs ) {	// don't forget this test!
		(A&)(*this) = (A&)rhs;	// invoke base class op= implicitly
		... // assign to the members specific to class B
	    }
	    return *this;
	}
Unless the base classes have some perverse design, this will always
do the right thing.

You can write an additional op= which takes an A&, using the same
schema.  Of course, you can't assign from the B parts of the rhs, since
it doesn't have any.  You will have to initialize them some other way.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
From: T.D.G.Sandford@bradford.ac.uk (TDG SANDFORD)
Newsgroups: comp.lang.c++
Subject: Result of delete operator applied to null pointer?
Date: 22 Jan 93 14:56:54 GMT
Organization: University of Bradford, UK
Originator: 90908106@columbia

Is the effect of applying the delete operator to a null pointer defined?

In particular, in the case

class x {
...
	~x();
...
};

fn1

{
	x *y;
... (including y = new x;)
	delete y;
}

should it be necessary to write

	if (y)
		delete y;

to prevent the destructor for x being called if y is in fact a null pointer?

(this appears to be the case for Borland C++ v3.1).
--
Thomas Sandford | t.d.g.sandford
Newsgroups: comp.lang.c++
From: chris@actrix.gen.nz (Chris Double)
Subject: Mixins
Organization: Actrix Information Exchange
Date: Fri, 22 Jan 1993 12:10:31 GMT

In article <1993Jan21.005415.2812@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
> 
> 	But your greatest achievement, Bjarne, in my opinion,
> was the name dominance rule, because, coupled with virtual
> bases and abstract classes that enables mixins.
> 

Hi.

I've read a lot on this newsgroup about how good mixins are but how
some compilers don't support them.

I've never come across this term before. Would somebody be able to
explain what the 'mixin' concept is?

Also what is wrong with the compilers that don't support it. I
understand Borland doesn't. So what isn't borland doing that it
should?

Your help would be appreciated!

Regards,

Chris Double.
chris@actrix.gen.nz
From: davidm@consilium.com (David S. Masterson)
Newsgroups: comp.lang.c++
Subject: Re: Virtual function call within constructors
Date: 24 Jan 93 22:57:57 GMT
Organization: Consilium Inc., Mountain View, California
In-reply-to: gschwarz@dcc.uchile.cl's message of 24 Jan 93 05:13:30 GMT
X-Posting-Software: GNUS 3.13  [ NNTP-based News Reader for GNU Emacs ]

>>>>> On 24 Jan 93 05:13:30 GMT, gschwarz@dcc.uchile.cl (Guillermo Schwarz
>>>>> Utrup) said:

> I have found that virtual functions are not handled as one could expect
> when called from a constructor.

Actually, it works exactly as expected according to the definition of C++.
You must realize that the parts of a class are not really available for use
until the constructor of that class has been called.  Therefore, if you have a
class definition like:

	A -> B -> C

then you know that, when constructing C, A and B must first be constructed.
Except for virtual functions, there is no way that A or B will try to make use
of some part of C.  When a virtual function is called, then the most derived
version of that virtual function that is currently available will be called.
The thing to realize is that while the A part of C is being constructed, then
the B and C parts of it are not yet available.
--
====================================================================
David Masterson					Consilium, Inc.
(415) 691-6311					640 Clyde Ct.
davidm@consilium.com				Mtn. View, CA  94043
====================================================================
I'm opposed to these unsupervised weekend furloughs for first-degree
murderers.
                -- George Bush, asked whether the Pledge of Allegiance
                   would be his only campaign issue in 1988.
Newsgroups: comp.lang.c++
From: kanze@us-es.sel.de (James Kanze)
Subject: Re: oopslooking for PerClass/SizeFreeList, oops
Organization: SEL
Date: 25 Jan 93 18:26:58

In article <1993Jan7.061533.8276@netcom.com> erc@netcom.com (Eric
Smith) writes:

|> Beware that Zortech has a reputation for releasing compilers with lots
|> of bugs.  I don't even want to upgrade my version 3.04 to 3.1 unless
|> they first publish a bug list showing which bugs have been fixed.  Some
|> of the bugs in 3.04 were very bad, such that I often had to reboot in
|> the middle of a compile.  Also, there were some quirks in their
|> interpretation of the C++ language, which wouldn't cause major problems
|> for beginning C++ programmers, but which made it hard to port big
|> programs to and from their compiler.

|> If cost is a factor, you should consider the Gnu version.  I think it
|> is or soon will be available on NT, and is already available on OS/2
|> and there is a DOS-extender version called DJGPP.  But I'm not sure
|> whether the Gnu version is better than Zortech 3.1, and I don't know
|> anyone who uses both, so they are hard to compare.

I use Zortech 3.?? under MS-DOS, and both GNU and Sun CC under Unix.

The GNU has to take the record as the buggiest compiler I have ever
used, and the earlier versions of the Zortech were pretty bad.  (I
might note that I was still learning C++ when I was using the early
versions of the Zortech, so I probably wasn't pushing them as hard as
I have the GNU.)

More generally, though...  C++ compilers in general seem very buggy.
Worse, many of the bugs are precisely those which will cause the most
problems for a beginner, and in every compiler, there seem to be some
that even the most trivial testing would uncover.  I know that C++ is
harder to compile than C, but that's no excuse for not doing any
quality control.
--
James Kanze                             email: kanze@us-es.sel.de
GABI Software, Sarl., 8 rue du Faisan, F-67000 Strasbourg, France
Conseils en informatique industrielle --
                   -- Beratung in industrieller Datenverarbeitung
Newsgroups: comp.lang.c++
From: stritzi@Physik.TU-Muenchen.DE (Peer Stritzinger)
Subject: Help: Where is the C++ product list??
Keywords: c++
Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
Date: Tue, 26 Jan 1993 06:44:34 GMT

Where do I get a recent version of the C++ product list?

Please answer by mail, too.

Thanks

--
Peer Stritzinger
stritzi@physik.tu-muenchen.de
Newsgroups: comp.lang.c++,comp.object
From: mahesh@elcaro1.ColumbiaSC.NCR.COM (Mahesh Zambani)
Subject: Re: Pros and cons of C++
Reply-To: mahesh@elcaro1.columbiaSC.NCR.COM
Organization: NCR Corp., Columbia
Date: Thu, 21 Jan 93 18:45:08 GMT

In article <1993Jan20.224816.19164@ucc.su.OZ.AU>, maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
|> In article <TMB.93Jan19223313@arolla.idiap.ch> tmb@idiap.ch writes:
|> >>>>>> On Tue, 19 Jan 1993 19:28:41 GMT, maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) said:
|> >tmb>That's the way I prototype in both dynamically (Lisp) and statically
|> >tmb>typed languages, including C++. I don't find the requirement that
|> >tmb>stubs have to be correctly typed to be a problem. 
|> >
|> >maxtal> 	I find this sort of thing is THE problem.
|> >
|> >Well, then simply ignore the undefined symbol errors that the linker
|> >is giving you and run your code anyway. On most machines, it will
|> >insert NULL for any address it doesn't know.
|> >
|> >					Thomas.
|> 	Cant. BC is strict: no object if compile fails,
|> no executable if link fails. Good thing in general,
|> you cant not notice an error when you try to run
|> a non-existant program.
|> 
|>         		JOHN (MAX) SKALLER

	So costomer also is very happy.
-- 

Mahesh Zambani                                mahesh@elcaro1.ColumbiaSC.NCR.COM

NCR MCPD , Columbia,SC 29170                  hello: off #803-791-6915
						     res #803-750-1863
_____________________________________________________________________________
Newsgroups: comp.lang.c++
From: wbc@lookout.it.uswc.uswest.com (Brad Cleavenger)
Subject: Inter-machine communications
Organization: US WEST Information Technologies
Date: Wed, 27 Jan 1993 16:43:20 GMT

Hello,
   I'm looking for a toolkit or CORBA implementation that will allow objects
to communicate between UNIX workstations, PC's and Mac's.  We are currently
using RPC but we would prefer a more object oriented approach.

   Any suggestions will be appreciated.


Brad Cleavenger
USWest Communications
wbc@uswest.com
From: jss@cs.bham.ac.uk (John Swapp-Sweet)
Newsgroups: comp.lang.c++
Subject: Re: where the name C++ came from
Date: 22 Jan 93 13:53:00 GMT
Organization: University of Birmingham

And MASM is C--
Newsgroups: comp.lang.c++
From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
Subject: Re: Dangling pointers & suggestions on future implementations of "delete"
Organization: MAXTAL P/L C/- University Computing Centre, Sydney
Date: Fri, 22 Jan 1993 19:33:22 GMT

In article <1993Jan20.213807.20740@cbnewsi.cb.att.com> rhw@att.com (Robert Wentworth) writes:
>In article <1993Jan19.193048.15022@borland.com> pete@borland.com (Pete Becker) writes:
>>In article <Jan18.210305.21697@yuma.ACNS.ColoState.EDU> bb760597@longs.LANCE.ColoState.Edu (Blake Buhlig) writes:
>>>I have been trying to find a way to overload the delete operator to set its
>>>pointer argument to NULL.  This would help prevent dangling pointer 
>>>dereferencing
>
>I agree: simply setting the deleted pointer to NULL or some illegal value
>leaves a big hole because other pointers can still point to the same
>now non-existent object.

	However, it is very useful to set a pointer to null after
deleting it because then subsequent deletes will do no harm.
Often, there is ONLY one pointer to each object.
How about:

	template<class T> 
	void destroy(T*& p){ delete p; p=0;}

Note: 'delete' cant set its argument to 0 because the argument
mightn't be an lvalue: 

	delete p+1;


-- 
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;------ SCIENTIFIC AND ENGINEERING SOFTWARE ---ph:  2 799 8223 --------
Newsgroups: comp.lang.c++
From: dvines@syl.dl.nec.com (Don Vines)
Newsgroups: comp.lang.c++,comp.lang.smalltalk
Subject: Re: CLASS variable in C++ ?
Date: 21 Jan 93 21:40:10 GMT
Organization: NEC Systems Lab., C&C Software Technology Center (Dallas, TX)



>>    How to implement Class Variable and Class Method in C++


you might consider taking a look at "Smalltalk's Runtime
Type Support for C++" in the January issue of C++ Report
-- 
Donald H Vines, Jr.
NEC Systems Laboratory, Inc.                  Phone: (214)518-3486             
1901 Gateway Dr.                              Fax  : (214)518-3552             
Irving, Texas 75038                           Email: dvines@syl.dl.nec.com
From: h8850513@d21.wu-wien.ac.at (Michael Tesar)
Newsgroups: comp.lang.c++
Subject: classes
Date: 22 Jan 1993 17:17:45 GMT
Organization: Wirtschaftsuniversitaet Wien
Distribution: world
NNTP-Posting-Host: d21.wu-wien.ac.at

Hello!

I have a problem with my classes matrix and amatrix.
Class matrix is for simple 
matrix operations, eg. multiplication
In this class I have overloaded the operator*

matrix operator*(matrix& mat);

This class is working well and now I wanted to write a new class amatrix
with all methodes of the matrix class - but I didnt like to change my 
matrix class. But in this new class I had to overload the operator* again.

amatrix operator*(const double dvalue);

But now I cannot use the multiplication of two amatrix objects.

The only way to solve this problem - I know - is to write the function
amatrix operator*(amatrix& mat);
again, but I think this is not C++ like. 

Is there any possibility to avoid this dublication?

Thank you,

MichaeL
C
D
Is there any possibility to avoid this dublication - better to--
From: dlong@cse.ucsc.edu (Dean R. E. Long)
Newsgroups: comp.lang.c++
Subject: inline member function (constructor) and templates
Date: 29 Jan 1993 03:04:30 GMT
Organization: University of California, Santa Cruz (CE/CIS Boards)
Distribution: world
NNTP-Posting-Host: oak.ucsc.edu

Should this piece of code work?  The non-template version does.

dl

--------

oak /tmp [118] % cat b.c
template <class T>
class A {
public:
    A(void);
};

template <class T>
inline A<T>::A(void) {}

int main(void)
{
    A<int> x;
}
oak /tmp [119] % /usr/local/C++3.0.1/bin/CC b.c
CC  b.c:
"b.c", line 8: error:   A <int >::A__pt__2_i() declared with external linkage and called before defined as inline
"b.c", line 8:   error detected during the instantiation of A <int >
 "b.c", line 14:         is the site of the instantiation
1 error
From: dak@tabaqui.informatik.rwth-aachen.de (David Kastrup)
Newsgroups: comp.lang.c++
Subject: Re: Is this C++ advice from an OO book true? (beginner question)
Date: 24 Jan 93 10:11:42 GMT
Organization: Rechnerbetrieb Informatik - RWTH Aachen
Distribution: world
NNTP-Posting-Host: tabaqui.informatik.rwth-aachen.de

sherman@unx.sas.com (Chris Sherman) writes:

>I don't understand one of the book's recommendations:

>  11.  Call virtual class constructors in dervied class constructors.

>     I pity the poor fools who have to spend nights and weekends searching
>     for the reason that a class variable occasionally takes on strange,
>     unexpected values .  .  .  only to find through their bleary eyes
>     that they forgot to allocate space for a virtual base (super) class,
>     so that storage is allocated for the base class's members.  Even if
>     the class has no members, declare it--you never know what future
>     changes will come back to haunt you (or the person who inherits your
>     mine field)!


>Or if this is very good advice, could someone give an example showing why
>it is true?

>This is a beginner question obviously--thanx for any help!

And the above book writes a beginner's answer. Constructors cannot be
virtual and I pity the poor fools who have to spend nights and weekends
only to find out that in C++ the type system is static, and so every
object's type is fixed from the beginning and types are managed by
the compiler. If the runtime had anything to do with the type system in
C++, maybe there would be such a thing as a virtual constructor.
From: jimi@vnet.ibm.com (Jim Meyers)
Date: Mon, 25 Jan 93 18:15:06 EST
Newsgroups: comp.lang.c++
Subject: Re: Shared Memory Objects

In <1993Jan25.105459.4799@hellgate.utah.edu> clark%asylum.cs.utah.edu@cs.utah.edu (Charles Clark) writes:
>
>Straying from the orignal subject a little, how can the location of the
>shared memory segments be coordinated?  The vtable location is fixed at
>link edit time, thus one would know then whether there is a conflict.
>Since the creation and attachment of the shared memory segment is at run-
>time, how can one ensure that the vm address of each of the cooperating
>processes will be available?
>
>       --Charles

This is an implementation-dependent problem. An easy way to do this
(in AIX) is to place all shared objects (and their vtables) in a single shared
library. AIX ensures that all processes accessing the shared library will
load the shared library code at the same virtual address. Thus, the location
of the vtables is consistent. To ensure that the virtual addresses of
shared objects is consistent, the process which instantiates the objects can
send the address to the clients. The clients can control the virtual address
of the shared memory segment via shmat(), and control the virtual address
of their "local" the shared memory objects via the new operator's placement
syntax.

Again, this is for AIX. This solution can also be implemented in OS/2 by
placing shared memory code (and vtables) in a DLL. Jordan describes Cfront-
dependent solutions for both SunOS and System V.

--Jim

-------------------------------------------------------------------------
Jim Meyers                           | Voice:    919-543-5999
IBM Networking Systems               | Fax:      919-543-1286
LAN Systems Workstation Technology   |
Research Triangle Park, NC 27709     | Internet: jimi@vnet.ibm.com
-------------------------------------------------------------------------


Newsgroups: comp.lang.c++
From: shrirang@b30.b30.ingr.com (Shrirang Moghe)
Subject: *#* C++ Training / SEMAPHORE *#*
Organization: Intergraph
Date: Mon, 25 Jan 1993 16:23:55 GMT


Fellow netters,

Do you people know of anybody that offers on site C++ training ?

We in Intergraph would like to have some one over to train a 
lot of people in C++ programming.

I know there is a company called SEMAPHORE that conducts C++
classes.

Any leads ?

Thanx for your time and help.

Regards,

shrirang

email: samoghe@b30.ingr.com
tel: 205/730-3005
  


Newsgroups: comp.lang.c++
From: kanze@us-es.sel.de (James Kanze)
Subject: Re: help with pass-by-reference
Organization: SEL
Distribution: usa
Date: 28 Jan 93 18:44:36

In article <1jq9o6INNfee@news.cerf.net> hlf@nic.cerf.net (Howard
Ferguson) writes:

|> In article <1993Jan22.231848.3690@nosc.mil> atkins@nosc.mil (Hugh T. Atkins) writes:
|> >Here's the setup, I have a class called Card and declare an array as
|> >follows
|> >
|> >
|> >Card myHand[5];  // this is an array of 5 playing cards
|> >
|> >I want to write a function which tests for pairs of cards and I want
|> >to use pass-by-reference but I can't figure out how to declare the
|> >function prototype.
|> >
|> >I'd like the function to return an int, something like this
|> >
|> >int hasPair( const Card& );
|> >
|> >

|> >if( hasPair( ?????? ) )
|> >  pairs++;
|> MAybe what you want is 
|> int hasPair ( const Card & *cardArray) {}

|> Because you can not move up an down the array with a reference i.e
|> references have no equivalent to pointer arithmatic.

|> But now that you are only passing a pointer so you might as well just
|> pass it by value. If you tried to write this as a reference to an 
|> array instead you would have the same effect because in C/C++ the 
|> name of an array is a pointer.

|> The bottom line is we should pass composite objects/structures/
|> aggregats/ any-thing-longer-than-a-couple-of-bytes as a reference,
|> but on the occations where more flexibility is required then a
|> pointer must be used. This is one of those cases.
|> with

Even better, why not declare a Hand object, thus:

	class Hand
	{
	public :
				Hand( StackOfCards& deck ) ;
		int		hasPair() const ;
	private :
		Card*		myCards[ 5 ] ;
	} ;

The constructor could arrange to obtain the five Cards needed (maybe
by calling the pick method in deck five times), and all of the member
functions could access them as needed.
--
James Kanze                             email: kanze@us-es.sel.de
GABI Software, Sarl., 8 rue du Faisan, F-67000 Strasbourg, France
Conseils en informatique industrielle --
                   -- Beratung in industrieller Datenverarbeitung
From: nm@dcs.ed.ac.uk (Neil Mackinnon)
Newsgroups: comp.lang.c++
Subject: Trouble With extern declaration in g++-2.3.3
Date: 21 Jan 93 13:09:06 GMT
Organization: Department of Computer Science, University of Edinburgh

I wonder if anyone out there could help me with a small problem I am 
having.

I am writing classes that will be linked with code generated by another 
program to form a simulation program that will carry out a simulation of a
systolic array. Within one of the classes I have a declarations

      extern int NO_OF_PORTS; 
	
      static portElem externalData[NO_OF_PORTS];

To say how many connections the array will have to the outside world.
it is an extern declaration because the code that is generated by my
main program will assign it a particular value according to the particular
array I am simulating. The compiler (g++-2.3.3) I am using is not allowing 
me to generate an unlinked object file for the class but is giving me 
the error message 

../include/arrayIo.h:22: variable-size type declared outside of any function

I have not been using C++ for long and have never seen this error before
if anyone could help I would be most greatful.


-- 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Neil A Mackinnon nm@uk.ac.ed.dcs 
(Moneys not everything but comes damm close)		 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Newsgroups: comp.lang.c++
From: erc@netcom.com (Eric Smith)
Subject: Re: C++ maintenance
Organization: Netcom - Online Communication Services (408 241-9760 guest)
Distribution: na
Date: Tue, 26 Jan 1993 06:11:32 GMT

In article <harvey.728009429@regina> harvey@opl.com (Harvey Reed) writes:
>For example, our conventions require:
>
>m<name>       (m)ember data of a class
>s<name>       (s)tatic data of a class
>a<name>       (a)ctual parameter to a method


Two suggestions:

1.  To make member names obvious in a member function, prefix each with
    "this->".  E.g., instead of invoking a member function as func()
    invoke it as this->func()  (Because prefixing with 'm' or whatever
    is a nonstandard convention which has to be learned by everyone
    who looks at your code, but this->func() has standard C++ meaning
    and is therefore "obvious" to everyone.)

2.  Keep all functions as short as possible, so you can see all local
    names without scrolling around.  Functions too big for that are
    also too big to be considered modular.  The bigger they are, the
    harder they are to maintain or modify.
Newsgroups: gnu.g++,comp.lang.c++
From: rgb@roadnet.ups.com (Rudy Bonefas)
Subject: g++ vs Sun C++ 2.1
Reply-To: rgb@roadnet.ups.com
Organization: Roadnet Technologies, Inc.
Date: Fri, 22 Jan 1993 15:45:45 GMT
Keywords: g++, c++

For financial reasons we are considering switching from the Sun 2.1 C++ compiler to
GNU's g++.  I have already obtained release 2.3.3 of gcc, built it, and am beginning
to run our massive C++ library through it.  However I have a couple of questions for
the net:

	1.  How do I build shared libraries with g++? I tried the -shared switch but
	     it tells me that it doesn't recognize that option.

	2.  Aside from the obvious financial benefits of g++, can any of you former
	 Sun C++ users inform me of the benefits/drawbacks to switching to g++.

	3.  I understand that g++ supports templates.  Where exactly is the 
	  documentation for how to create template classes?  The only temmplate
	  implementation which I am familiar with is ODI's compiler. 

Thanks in advance for your responses,

Rudy G. Bonefas (RGB - graphics is my middle name)



Newsgroups: comp.lang.c++