HDTenEightyP/NetNews huggingface dataset:
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: "Generic" Objects in a list.
Organization: Computer Science, University of Melbourne, Australia
Date: Mon, 28 Sep 1992 15:12:38 GMT

riipinen@dxcern.cern.ch (Petri Juhani Riipinen) writes:

>class box { <varibles etc...>
>public:   <initialization>
>	  void draw();
>}
>
>class circle { <also some variables etc.>
>public:      <initialization>
>	     void draw();
>}
[...]
>Now, I want to make a linked list of these objects:
>
>typedef struct sdef { void *obj;
>		      struct *next;
>		    } one_object;
[...]
>Now, that works, but is that really the only way of doing it? Because,
>somehow, I get the feeling, that this not quite according to the principles
>of object oriented programming.

box and circle share a common interface; a good way to express this in C++
is to use an abstract base class:

	class shape {
	public:
		virtual void draw() = 0;
	}

	class circle : public shape { ... };
	class box    : public shape { ... };

Then if you wish to refer to a drawable object, but don't know whether it
is a circle or a box, refer to it as a shape:
	struct list {
		shape *obj;
		list *next;
	};

Because the draw() method is "virtual", whenever you invoke the draw()
method using a pointer or reference to shape, the correct draw() method
corresponding to the object in question will actually be invoked:
	shape *obj;
	obj = new box(...);
	obj->draw();		// calls box::draw
	delete obj;
	obj = new circle(...);
	obj->draw();		// class circle::draw
	delete obj;

-- 
Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
This .signature virus is a self-referential statement that is true - but 
you will only be able to consistently believe it if you copy it to your own
.signature file!
From: rotherme@bcstec.ca.boeing.com (Pete Rothermel)
Newsgroups: comp.lang.c++
Subject: form() with ostreams using Borland
Keywords: form ostream Borland
Date: 1 Oct 92 18:00:08 GMT
Organization: Boeing Computer Services, Seattle

I know that this question keeps coming back but I
couldn't find it in the FAQ. What include file
do I need to include to use the older version of
<< operator that supports formated output with
the keyword "form" ?

I having problems in Borland C++. 


#include <????>

main()
{
   int ival = 12 ;
   float pi = 3.14159 ;

   cout << form( "ival\t = %d\t\t pi\t = %f\n" , ival , pi ) ;
}

Thanks in advance
Pete R
From: Robert.Stewart@mailbox.bison.mb.ca (Robert Stewart)
Newsgroups: comp.lang.c++
Subject: Re: C++ Style
Date: 24 Sep 92 18:25:37 CST

Organization: Compaq Computer Corporation
Reply-To: roberts@cpqhou.UUCP (Robert Stewart)

In article <1992Sep23.140340.3641@ultb.isc.rit.edu> mpk9172@ultb.isc.rit.edu (M.P. Kirby) writes:
>I'm an old C hack trying to learn this new fangled C++ thing.  In reading
>stroustrups book, I see that C++ Allows a variable to be declared anywhere.
>
>  ...example deleted.
>
>Is there a stylistic advantage for puting the declarations closer to where
>I use them? 

Actually, there are important functional reasons for this in C++.  Remember
that the "variable" that you are declaring is very often an object.

You will find yourself constructing objects in the "middle" of your code,
since you often don't have the information to pass to the constructor until
you get there.

Bob Stewart
roberts@compaq.com

 * Origin: The Electronic Mailbox (1:348/7.0)
From: murison@cfa203.HARVARD.EDU (Marc A. Murison, RG)
Newsgroups: comp.lang.c++
Subject: Re: static member and access control?
Date: 6 Oct 92 13:37:49 GMT
Organization: Smithsonian Astrophysical Observatory, Cambridge, MA,  USA

From article <1992Oct5.125039.16602@news.uni-stuttgart.de>, by LANG@nvdv01.ind.e-technik.uni-stuttgart.de (MARTIN LANG):
> 
> [...] 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. [...]
> class Test
> {
>   private:
>   enum E1 { a,b};
>   static E1 e;
> };
> E1 Test::e=Test::a;

Borland 3.1 complains with an error (no access to private...).

------
Marc A. Murison  Smithsonian Astrophysical Observatory  murison@cfa.harvard.edu
#include <fstream.h>
void main( void ) { 
ifstream in("obquote.txt",ios::in); char c; while( in.get(c) ) cout.put(c); }

-----
test
From: ark@alice.att.com (Andrew Koenig)
Newsgroups: comp.lang.c++
Subject: Re: declare keyword, type inference
Date: 4 Oct 92 14:08:17 GMT
Article-I.D.: alice.23794
Reply-To: ark@alice.UUCP ()
Organization: AT&T Bell Laboratories, Murray Hill NJ

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

> C++ made a decision to go with overloading. Overloading doesn't
> coexist well with type inference.

But this isn't type inference in the sense you mean.  Rather, it is
an attempt to exploit the fact that in C++ it is always possible to
determine the (static) type of an expression, so why not allow a
variable to be defined as having the same type, whatever it is?

In other words, when writing something like

	declare x = y;

we are not allowed to infer anything about the type of y.  We are
just saying that whatever type y has, x should have the same type.

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.  If starting with a clean sheet of paper, it would
seem to be nicer to say that the default type is the same as that
of the initializing expression (with any top-level const, volatile,
or reference stripped), and there is no default in the absence of
an initializing expression.  So, for example:

	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
	}

and so on.  I use `auto' here because it is already part of the language.
Moreover, using `auto' in this context immediately answers all questions
about how to say that a variable of unspecified type is a const or a
reference, because the syntax is already known.

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.  The question therefore comes down to whether
it's worth adding a new keyword and, if so, exactly what the rules
for it should be.
-- 
				--Andrew Koenig
				  ark@europa.att.com
From: michel@vedge.UUCP (Michel Trudeau)
Newsgroups: comp.lang.c++
Subject: Re: Why does this not work? (C/C++ linkage)
Date: 25 Sep 92 16:25:59 GMT
Distribution: comp.lang.c++
Organization: Visual Edge Software, St. Laurent, Quebec

maffeis@ifi.unizh.ch (Silvano Maffeis) writes:
: Hello!
: 
: I'm trying to call a C++ method from within a C module using
: a POINTER TO THE METHOD:
: 
: This is my C module:
: =============================
: 
: void starter(void (*f)(int,int)){
:   (*f)(1,2);		/* invoke function with arguments (1,2) */
: };
: 
: =============================
: 
: And this the C++ module:
: 
: =============================
: 
: #include <stream.h>
: 
: extern "C" {
:  void starter(void (*)(int,int));
: };
: 
: class foo{
: public:
:   foo(){};
:   ~foo(){};
: 
:   void bar(int a, int b){
:     cout << "a= " << a << "\nb= " << b << "\n";
:   };
: };
: 
: main(){
:   foo *f= new foo();
:   ::starter((void (*)(int,int)) &f->bar);  /* function to invoke is f->bar */
: };
:   
: =============================
: 
: The resulting program would display 
: 
: a= 1
: b= 2
: 
: if the arguments were passed correctly to foo::bar. What I obtain is
: 
: a= 2
: b= 34501
: 
: Argument #1 is lost!
: I use gcc 1.41 and g++ 1.41, but had the same problem with gcc 2.2.
: Any idea? (Please e-mail, I will summarize interesting comments).
: 

When you call a C++ method from a C function, you must include the hidden
'this' parameter as the first parameter;

example:
			
    In Main:

			::starter((void *)f, (void (*)(void *, int, int)) &f->bar);

    starter function must be:

		 void starter(void *objectPointer, void (*f)(void *, int,int)){
			 (*f)(objectPointer, 1,2);		/* invoke function with arguments (1,2) */
		 };

Regards,
Michel Trudeau
Newsgroups: comp.lang.c++
From: agrafiot@wl.com (Dimitris Agrafiotis)
Subject: Can a class inquire about subclass data members by name?
Organization: Warner Lambert / Parke-Davis
Date: Wed, 30 Sep 1992 14:56:31 GMT


I've just started learning C++ and have the following questions:
1. Can a class find all its subclasses ?
2. If 1 is true, can it find the names of the data members of its subclasses ?
3. If 1 and 2 are true, can you write a piece of code in the superclass
   that sets the values of these data members ?
Note that the subclass data members of interest are not inherited from
the superclass.

Thanks
--
From: Daniel.Parmet@bbs.oit.unc.edu (Daniel Parmet)
Newsgroups: comp.lang.c++
Subject: MPW C++
Date: 2 Oct 92 01:50:38 GMT
Organization: Extended Bulletin Board Service

What files or libraries are needed to compile and link C++ programs using
MPW C++?

More specifically, I am trying to include the <iostream.h> file, but when
linking, the compiler says that it cannot find this file.  I thought that it
would be in the CPlusLib.o library, but it does not seem to be.

Please reply by mail to udasbell@mcs.drexel.edu.

Thank you.
--
   The opinions expressed are not necessarily those of the University of
     North Carolina at Chapel Hill, the Campus Office for Information
        Technology, or the Experimental Bulletin Board Service.
           internet:  bbs.oit.unc.edu or 152.2.22.80
Newsgroups: comp.lang.c++
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: constructors & sizeof in C++
Organization: Computer Science, University of Melbourne, Australia
Date: Fri, 2 Oct 1992 18:25:11 GMT

david@csource.oz.au (david nugent) writes:

>Is this sort of constructur legal/advisable?
>
> class Foo
>     {
>     private:
>         int mem1;
>         int mem2;
>         char mem3[10];
>         .
>         .
>         .
>     public:
>         Foo (void);
>         .
>         .
>         .
>     };
>
> Foo::Foo (void)
> {
>
>     memset (this, 0, sizeof(Foo));          // Or bzero()
>     .
>     .
> }

Syntactically, it is legal.
It is however most inadvisable :-)

>Is sizeof(Foo) guaranteed to be the size of the structure containing the
>declared object's non-static data? 

No.

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

Yes, it may. Normally objects of classes with any virtual functions will
contain a pointer to the table of virtual functions (the "vtable")
for that class. Your memset() would overwrite the vtable pointer.

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

Yes, this is "safer". It is still not "safe".
You also need to ensure that the class contains no pointers or floating
point members, because NULL pointers and floating point 0.0 need not
be represented by a bit-pattern of all zeroes.

Frankly I think that the efficiency gain in using memcpy - if any (a smart
compiler would produce the same code anyway) - is not going to be worth the
maintenance hassle except in the most extreme circumstances.

>I also assume sizeof() also takes into account the size of base class
>non-static members?

Yes.

-- 
Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
This .signature virus is a self-referential statement that is true - but 
you will only be able to consistently believe it if you copy it to your own
.signature file!
Xref: sparky comp.lang.c++:14393 comp.std.c++:1272
From: swf@teradata.com (Stanley Friesen)
Newsgroups: comp.lang.c++,comp.std.c++
Subject: Re: Conceptual Constness
Keywords: const, const member, lazy
Date: 1 Oct 92 17:36:02 GMT
Reply-To: swf@tdat.teradata.com (Stanley Friesen)
Distribution: world
Organization: NCR Teradata Database Business Unit

In article <1adbr4INNkno@agate.berkeley.edu> jbuck@forney.berkeley.edu (Joe Buck) writes:
|In article <1ackm3INNno2@fido.asd.sgi.com> linton@marktwain.rad.sgi.com (Mark Linton) writes:
|>This subject has been visited in the past.  There have been several language
|>proposals, though I don't know if any are being taken seriously.
|
|I, for one, hope that the ~const proposal is taken seriously.  I'd like
|to go even further, and permit objects with constructors to be in ROM
|in cases where this is possible (it is possible if the initialization
|can be done at compile time and the relevant constructor is inline).
|This could already be done, except that the language in the ARM, as
|clarified by the ANSI committee, appears to forbid it (because it
|blesses cast-away-const for all objects with constructors).

I agree, I really *detest* cast-away-const.  It needs to be thrown away.
Of the alternative proposals, the ~const one seems the best.
[If *any* of the alternativess are blessed, cast-away-const *must* go].
-- 
sarima@teradata.com			(formerly tdatirv!sarima)
  or
Stanley.Friesen@ElSegundoCA.ncr.com
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: Tue, 29 Sep 1992 15:14:22 GMT

In article <d8_p1zq.feustel@netcom.com> 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?
>-- 

	It would tend to be a bit OS/processor dependent. 

	The problem is the vtbl pointers. YOu do want to be
able to recompiler your program to change the implementation of the 
functions if not the interface.

	On a decent 386 OS you could arrange it using segments
for the vtbls and using callgates for the function pointers.
You would have to bind the selectors to fixed numbers somehow.
(Changing the order of modules in the link would stuff it up
otherwise)

	Even if it could be done it might not be the best way
so I've been told by those knowing more than I. I actually
suggested memory mapping the whole disk drive. No more
file accesses at all--everythings memory.

-- 
;----------------------------------------------------------------------
        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: sakkinen@jyu.fi (Markku Sakkinen)
Subject: Re: BREAK, CONTINUE, multiple RETURNs, GOTOs and EXCEPTIONs
Organization: University of Jyvaskyla, Finland
Date: Wed, 30 Sep 1992 11:12:36 GMT

In article <2525@devnull.mpd.tandem.com> rgp@mpd.tandem.com (Ramon Pantin) writes:
> ...
>It is funny that exception handling being fashionable in C++ many
>people believe that it is the answer to all their problems.  C++ exception
>handling is nothing more than a glorified longjmp and a glorified setjmp
>(the try block) adapted to C++ so that objects on the stack get properly
>destroyed.  I'm not saying that it is not usefull.
>
>I sugest that you continue to use gotos or flags (how about a nice
>nid-fucniton return?) to get out of your nested loops on error conditions.
>IMHO, exception handling use in that case would be overkill.

There is sense in this.
In the general case, exceptions may be, in some way, more difficult
to reason about than the other devices mentioned on the subject line.
Namely, with the other statements the target of the jump can be seen
statically from the program text, but exception resolution happens
at run time.  This is the case as well in most other languages that have
exceptions;  BETA is one example that resolves exceptions statically.

----------------------------------------------------------------------
Markku Sakkinen (sakkinen@jytko.jyu.fi)
       SAKKINEN@FINJYU.bitnet (alternative network address)
Department of Computer Science and Information Systems
University of Jyvaskyla (a's with umlauts)
PL 35
SF-40351 Jyvaskyla (umlauts again)
Finland
----------------------------------------------------------------------
Newsgroups: comp.lang.c++
Subject: C++ programming standards
From: srlncnc@gopher.dosli.govt.nz (Chris Crook)
Date: Fri, 2 Oct 1992 19:23:53 GMT
Organization: Department of Survey and Land Information, New Zealand


I am looking for any information available about defining standards for
C++ programming.  Our organisation needs to get some standards into place
to ensure that we can all benefit from re-using code and to ensure that
the code is maintainable.

I think there have been some postings on coding standards recently - but
unfortunately they have disappeared from our system.

I would be interested to hear from anyone who can offer advice on
programming standards or who knows where such information is available.
Also I would be interested in any references to the same.

I cannot use anonymous ftp from our site (if this is relevant).

Many thanks
Chris Crook
Newsgroups: comp.lang.c++
Subject: cBase information requested
From: kallman@idicl1.idi.battelle.org
Date: 3 Oct 92 22:41:11 EST
Organization: IDI-Dublin
Nntp-Posting-User: kallman

Within the past 30 days, the author of cBase, which is a set of classes
for manipulation of xBase database files and indexes, posted the source 
code for these classes to this newsgroup.  Could someone please send me
the Internet address of this author?

Thanking you in advance,
Joel

-- 
_______________________________________________________________________________
| Joel R. Kallman		             kallman@idicl1.idi.battelle.org
| Software Developer      
| Information Dimensions Incorporated
| 5080 Tuttle Crossing Boulevard
| Dublin, Ohio  43017-3569
Newsgroups: comp.lang.c++
From: pete@cssc-syd.tansu.com.au (Peter Alexander Merel)
Subject: Re: Good book on C++
Organization: AOTC - CSSC
Date: Wed, 30 Sep 1992 01:00:31 GMT

berrios@aps.anl.gov (Joe Berrios) writes:

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

No. The standard reference (and ANSI base document) is the ARM, as discussed
in the FAQ. The full poop is:

`Annotated C++ Reference Manual', Ellis and Stroustrup, Addison/Wesley
ISBN 0-201-51459-1

-- 
Internet: pete@cssc-syd.tansu.com.au   UUCP: {uunet,mcvax}!munnari!cssc-syd!pete
Snail: 1/18-20 Orion Road, Lane Cove NSW 2066 Australia    Phone: +61 2 911 3130
"Nothing is pulling it. Nothing is pushing it. It must be devil's work!"
Xref: sparky comp.lang.c++:14549 comp.std.c++:1317 gnu.g++.help:1303
From: leonard@cs.utwente.nl (Leonard Thierry)
Newsgroups: comp.lang.c++,comp.std.c++,gnu.g++.help
Subject: C++ Parser Class wanted
Keywords: parsing, parser, grammar, language
Date: 5 Oct 92 12:36:05 GMT
Followup-To: comp.lang.c++,comp.std.c++,gnu.g++.help
Organization: University of Twente, Dept. of Computer Science
To: gnu-g++-announce@uunet.uu.net

Does anyone know whether there exists a public domain
C++ parser class or something like that.

I am interested in a (simple) parser that can parse
a context-free grammar. It doesn't necessarily have
to be an efficient one.

It is supposed to be used in a neuralnet class as
a compiler for a very simple neural net user language.

Thanks a lot in advance for any help!


Leonard Thierry
-- 
=======================================================================
|    Leonard Thierry    | Computer Science Dep.|  Research keywords:  |
| leonard@cs.utwente.nl | University of Twente | nat.lang.;neur.nets; |
|                       |     Netherlands      | know.rep.;logics;c++ |
=======================================================================
Newsgroups: comp.lang.c++
From: kanze@us-es.sel.de (James Kanze)
Subject: Re: Sigh. So, what is a proper class definition ?
Organization: SEL
	<1992Sep23.162216.21027@ucc.su.OZ.AU>
Date: 29 Sep 92 20:26:32

In article <1992Sep23.162216.21027@ucc.su.OZ.AU>
maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:

> In article <4277@seti.UUCP> ziane@nuri.inria.fr (ziane mikal -) writes:
> >
> >A related problem is about the "insert" method of a list package.
> >Should "insert" be considered as a defining property of a list class ?

> 	IMHO, yes.
> > 
> >Intuitively it seems weird, since one might want to use lists whithout
> >adding new elements. The very concept of a list seems, at first,
> >well defined by access methods. However, if we look at a recursive
> >definition of a list, there is likely to be an axiom for insertion.
> >That is a complicated list is defined in terms of operations on simpler
> >ones.
> >But shouldn't insertion be defined as a constructor, if we only
> >want to manipulate constant lists ?
> >
> >Mikal (Mikal.Ziane@inria.fr)

> 	A list is an array with insert and remove operators.
> Arrays have [] access and a length operator. I dont bother
> with iterators for lists---integers do just fine. This
> approach is inefficient, but a cache can improve that.
> (If I really want ultra fast access I can use 'first' and 'next',
> but I hardly ever bother)

And what happens if efficiency later becomes important.

I almost never use int (for anything).  It's almost always better to
whip up a small class.  How much work would it be to encapsulate your
int in an iterator class?  And if efficiency does become important,
re-implement the iterator class in a more efficient manner.  Without
breaking any code that uses it.

Once you've used int as the iterator, you're stuck.  Any improvements
break user code.

BTW, I'm not saying that the lack of efficiency is bad.  Just
encapsulate it so you can change later, without too much effort.
--
James Kanze                         GABI Software, Sarl.
email: kanze@us-es.sel.de           8 rue du Faisan
                                    67000 Strasbourg
                                    France
Newsgroups: comp.lang.c++
From: mittle@siena.watson.ibm.com (Josh Mittleman)
Subject: Re: Can a class inquire about subclass data members by name?
Date: Wed, 30 Sep 92 16:59:30 GMT
Organization: IBM T. J. Watson Research


In article <1992Sep30.145631.26176@wl.com>, agrafiot@wl.com (Dimitris
Agrafiotis) writes:

> 1. Can a class find all its subclasses ?

No.  A class knows nothing about its sub-classes.  The principles of
encapsultation and re-usability are incompatible with such knowlege.

===========================================================================
Josh Mittleman (mittle@watson.ibm.com)
J2-C28 T.J. Watson Research Center, PO Box 704, Yorktown Heights, NY  10598
From: ap88431@cs.tut.fi (Porma Asmo Ari Juhani)
Newsgroups: comp.lang.c++
Subject: Re: Exception handling & Borland C++ 3.1
Date: 28 Sep 92 11:35:41
Organization: Tampere Univ. of Technology, Finland.
Distribution: world
NNTP-Posting-Host: kaarne.cs.tut.fi
In-reply-to: das11@jaguar.uofs.edu's message of 28 Sep 92 04:19:10 GMT

In article <1992Sep27.231910.1@jaguar.uofs.edu> das11@jaguar.uofs.edu writes:



	 When using a throw within a class, I get the error that I can
	 not define a throw in an inline function.  Also, when I put a
	 try in the source, it tells me illegal syntax.

   Question :    Does anyone know how BORLAND C++ handles exceptions?

I think it doesn't support ecxeption handling yet...Borland has announced
that it will make exp. handling to next version...

/ap









--
     // Asmo Porma  (OH3MWG)        Tampere University
    // Keskisenkatu 6 A 7           of Technology
\\ // SF-33710 Tampere, Finland     Internet: ap88431@cs.tut.fi
 \X/ Tel: no telephone at the moment