HDTenEightyP/NetNews huggingface dataset:
From: brister@decwrl.dec.com (James Brister)
Subject: consts inside a class?
Organization: DEC Western Software Lab
Date: 15 Sep 92 18:53:09

I've been putting lines like

	const int maxLineSize = 1024 ;

in global scope, but would rather have it inside the class declaration.
However, my compiler chokes on 

    class A 
    {
      public:
	const int foo = 10 ;
	int a ;
    };

    main (int argc, char **argv) 
    {
	A z ;

	z.a = A::foo ;
    }
 
with:

    test.C:4: error: Invalid pure specifier.

so I suppose this way isn't legal. Is there a legal way to do this, or am I
stuck with my current method?

Thanks

James
--
James Brister                                           brister@wsl.pa.dec.com
DEC Western Software Lab., Palo Alto, CA                        decwrl!brister
Newsgroups: comp.lang.c++
From: dada@us-es.sel.de (David Ashley Davies)
Subject: Re: Virtual methods
Keywords: interrupt handler virtual methods
Organization: SEL-Alcatel LTS Dept. US/ES
Date: Tue, 15 Sep 92 09:59:40 GMT

In article <1992Sep14.145950.7661@us-es.sel.de>, brendan@us-es.sel.de (Dalton) writes:
|> feustel@netcom.com (David Feustel) writes:
|> 
|> |> Coplien's book "Advanced C++" makes the point that very little overhead
|> |> would be incurred in most programe even if all functions were declared
|> |> virtual and that some programs might even run faster than equivalent C
|> |> programs using switch constructs to achieve the same effects.
|> 
|> This reminds me of a question which I've been meaning to ask for some
|> time now. Ignoring performance issues, why would one not declare every
|> method in a class virtual? What circumstances might preclude its use?

1/ Interrupt handler.  Has to be static.
(Or does anyone out there know of some wonderful o-o hardware that
 gets around this problem?)

2/ Prevent subclass override of method definition.

As far as overhead is concerned, there were reported speed improvements of
10-20% using object pascal (all virtual) and the MacApp class library against
conventional case (switch) code processing the event loop.  On the other hand,
the bloat in executable size was also about 20%.  Swings and roundabouts.

David.
_______________
David A. Davies
From: dbox@net4.ics.uci.edu (Don Box)
Subject: iostream differences (CFRONT2.1 vs 3.0 vs ANSI proposals)
Newsgroups: comp.lang.c++
Reply-To: dbox@ics.uci.edu (Don Box)
Organization: UC Irvine
Date: 11 Sep 92 02:45:52 GMT

Can someone summarize the differences between the three versions of
iostreams listed above?  My site doesn't have CFRONT3.0 yet, and I am
REALLY curious as to what's going to change from 2.1.

A few quick questions, although any info would be appreciated:

	1) Are streambuf::xsputn () and streambuf::xsgetn () still
           around?  They're in the 2.1 code, but the man page and AT&T
           library manual makes no mention of them.

	2) Have the put/get calls all been (void*,size_t)'ed?

	3) Is the mechanism for disabling buffering still the same?


Thanks in advance,
Don Box
From: gordie@kaleida.com (Gordie Freedman)
Newsgroups: comp.lang.c++
Subject: Question on Borland C++ and new
Date: 9 Sep 92 01:38:46 GMT
Reply-To: gordie@kaleida.com
Organization: Happy hacker bait and tackle shop

I am using Borland's latest C++ on DOS, and when I try to "new" storage it sometimes returns 0, even though I haven't used that much storage from the heap yet.

The case is that I "new" about 32kbytes in 8 calls to new, and then make a call to 
new for another 40k. Suspiciously it looks like I either exceeded 64k and new 
will only give me 64k of storage, or I need to use "far" pointers.

The code I wrote runs fine on the Sparc, and is supposed to be platform independant,
so I don't want to muck up the code with far, so I'm hoping there is some way to 
tell the compiler to generate far pointers all the time. Here's an example:

// In Object.H

class Object {
// This object is 10 bytes in size
private:
	char data [10] ;
public:
	const char* const getData (void) const { return data ; }
} ;


class Thing {
public:
	void allocate (int num) ;
	Object* get (int index) const { return &objects[index] ; }
private:
	Object* o1 ;
	Object* o2 ; 
	Object* o3 ;
	Object* o4 ; 
	Object* o5 ;
	Object* o6 ; 
	Object* o7 ;
	Object* o8 ; 

	Object* objects ;
} ;

// In Object.C

void Thing::allocate (int num) 
{
	o1 = new Object [num] ;
	o2 = new Object [num] ;
	o3 = new Object [num] ;
	o4 = new Object [num] ;
	o5 = new Object [num] ;
	o6 = new Object [num] ;
	o7 = new Object [num] ;
	o8 = new Object [num] ;

	// The next allocate fails, at least objects is set to 0 after it
	// Do I need to make objects "Object far* objects" to house a 4 byte
	// pointer?
	objects = new Object [num * 10] ;
}

int
main (unsigned int argc, char** argv)
{
	Thing thing ;
	thing.allocate (400) ;
	return 0 ;
}

So I could do this:

#ifdef DOS
#define FAR far
#else
#define FAR
#endif

and then make all of the pointers far pointers. I'd rather not do this though.
Actually, I'm not sure if my theroy on "far" is even right, I may be doing 
something else wrong. 

Any suggestions? I'm having trouble with our newsreader (the server actually), so 
email is preferred if possible. Thanks in advance ...

---
Gordie Freedman: gordie@kaleida.com Sigs are for kids


Newsgroups: comp.lang.c++
From: adk@Warren.MENTORG.COM (Ajay Kamdar)
Subject: Re: pointer to member function.
Organization: Mentor Graphics Corp. - IC Group
Date: Mon, 7 Sep 1992 18:06:58 GMT

In article <1992Sep5.015422.2429@unixland.natick.ma.us> dlb@unixland.natick.ma.us (David L. Briggs) writes:
>	A simple question.  If you have a class that has several functions
>with the same name that are overloaded, how can you take the address of one
>of these function?

class A {
public:
	int foo(int);
	int foo(char *);

	int bar(int);
	int bar(char *);
};

main()
{
	int (A::*p1)(int);
	int (A::*p2)(char *);

	p1 = &A::foo;	// points to int A::foo(int)
	p2 = &A::foo;	// points to int A::foo(char *)

	p1 = &A::bar;	// points to int A::bar(int)
	p2 = &A::bar;	// points to int A::bar(char *)
}


- Ajay

-- 
I speak for none but myself.

Ajay Kamdar                               Email : ajay_kamdar@mentorg.com
Mentor Graphics, IC Group (Warren, NJ)    Phone : (908) 580-0102
Newsgroups: comp.lang.c++
From: eny@ermes.enea.se (Erik Nykvist)
Subject: Re: Ellemtel Rules and recommendations
Organization: Project ERMES, Teli Telecom Sweden
Date: Sun, 13 Sep 1992 10:52:59 GMT

karel@cv.ruu.nl (Karel Zuiderveld) writes:
> Where can I ftp a copy of "Programming in C++ - Rules and
> Recommendation" written by Mats Henricson and Erik Nyquist of Ellemtel
> Telecommunications Systems Laboratories?
> 
> I have lost the original postscript file.
> 
> karel
> 
> -- 
> Karel Zuiderveld                            E-mail: karel@cv.ruu.nl
> 3D Computer Vision - Room E.02.222          Tel:    (31-30) 506682/507772
> Academisch Ziekenhuis Utrecht               Fax:    (31-30) 513399
> Heidelberglaan 100, 3584 CX Utrecht, The Netherlands

You (maybe) can get the document by anonymous ftp from:
euagate.eua.ericsson.se

Look in the directory eua/c++!

I no longer works for Ellemtel so this may have changed.

Send a mail to Mats Henricson if there are any problem:
mats.henricson@eua.ericson.se

Erik Nyquist
From: brendan@us-es.sel.de (Dalton)
Newsgroups: comp.lang.c++
Subject: Virtual methods
Date: 14 Sep 92 14:59:50 GMT
Organization: SEL-Alcatel LTS Dept. US/ES

feustel@netcom.com (David Feustel) writes:

|> Coplien's book "Advanced C++" makes the point that very little overhead
|> would be incurred in most programe even if all functions were declared
|> virtual and that some programs might even run faster than equivalent C
|> programs using switch constructs to achieve the same effects.

This reminds me of a question which I've been meaning to ask for some
time now. Ignoring performance issues, why would one not declare every
method in a class virtual? What circumstances might preclude its use?

-- 
Brendan J. Dalton (brendan@us-es.sel.de)
----------------------------------------
Ritheann an fear seo ar phoitin
Newsgroups: comp.lang.c++
From: steve@taumet.com (Steve Clamage)
Subject: Re: Answers on a postcard...
Organization: TauMetric Corporation
Date: Mon, 14 Sep 1992 17:25:14 GMT

eric@tfs.com (Eric Smith) writes:

>In article <1992Sep13.160033.7735@taumet.com> steve@taumet.com (Steve Clamage) writes:
>>It would be possible to change the rules so that order of evaluation
>>was preserved for overloaded versions of operators "&&", "||", and ",".
>>Any proposal to do so would have to show some good reason why the

>Why not just require all function arguments to always be evaluated left
>to right?  That would simplify the language, shorten its description,
>make it easier for novices to learn, and would not break any existing
>bug-free code.  I never did understand the value of leaving such
>questions open, which accomplishes nothing useful and makes bugs
>behave differently with different compilers.

The current rule (undefined order of evaluation of function arguments)
is inherited from C (K&R1, p50).  C had the rule in order to allow the
most efficient code generation or compiler operation.  Prior to the C
standard, different compilers accordingly used (and still use)
different methods for argument evaluation and passing.

To see one difficulty, C compilers typically push arguments onto the
stack rightmost first.  This assures the called routine that the
first (leftmost) argument is on the top of the stack.  If you pass
arguments on a stack, you have to do this for C, where no prototype
is needed, or for C and C++ with variable-argument functions.  (Of
course, other argument-passing methods may be used.)

If the arguments must be evaluated left to right, it forces the compiler
either to keep around arbitrary amounts of argument calculation, or to
create extra temps.  (I knew of one compiler which generated code to
reverse the arguments on the stack after pushing them, to handle
inter-langauge calls with different argument orders.)

When we propose adding a language restriction which was not there
originally, we have to ask what problem does it solve, how severe
and how common is the problem, and what is the cost of the solution.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Vice Chair, ANSI C++ Committee, X3J16
Newsgroups: comp.lang.c++
From: mikea@ruby.aruba.UUCP (Mike Arsenault)
Subject: Re: I/O streams in ANSI definition?
Date: Thu, 10 Sep 1992 19:29:13 GMT
Organization: Project Zed

In article <1992Sep9.163629.27855@taumet.com>, steve@taumet.com (Steve Clamage) writes:
|> d9patrik@dtek.chalmers.se (Patrik Larking) writes:
|> 
|> >I currently own the C++ Primer by Lippman and The Annotaded reference manual.
|> >Neither of theese treat the I/O stream fully and I don`t want to bye a complte
|> >new book! 
|> > Are there any seperate publications witch only treat the I/O library.
|> 
|> You can order the C++ library manual from AT&T (or maybe USL) which
|> describes the original AT&T implementaion of iostreams in detail.
|> You will have to get ordering information from someone else.
|> 
-- 
Does any one have this ordering information ??
*******************************************************************************
* Mike Arsenault                |Internet Style: aruba!mikea@uu2.psi.com      *
* Systems Programming           |UUCP     : ...!uunet!uu2.psi.com!aruba!mikea *
*******************************************************************************
From: rmartin@thor.Rational.COM (Bob Martin)
Newsgroups: comp.lang.c++
Subject: Re: C++ Memory Management
Keywords: Memory, Heap, new, delete
Date: 5 Sep 92 13:48:34 GMT
Distribution: ca

acanter@sdcc3.ucsd.edu (Adriaan Canter) writes:


|Hello, I've noticed that Borland Turbo C++ (v 1.0) will actually reserve 16
|bytes when the "new" function is used to allocate space for a 2 byte
|integer, i.e. the following code:

|int * intptr;
|intptr = new int;

|will allocate 16 bytes, as measured using the "coreleft()" function,
|under the small memory model. A subsequent second allocation of this type will
|fit the second integer into the first 16 byte space allocated, but a third call
|will block off an additional 16 bytes, and so on, so that 4 two-byte integers
|will take up 32 bytes of space, for example. I guess this happens because some
|space is reserved to point to the next location in the heap, although the
|amount seems excessive. This is pretty wasteful of course, if I want to
|dynamically allocate alot of structures. Is there anyway I can control how
|much memory is actually reserved when the "new" function is called? Do the
|newer versions of C++ have some memory managment classes (as I've over-heard)
|that can fix this? Or do I have to finagle my own scheme, overloading the
|"new" and "delete" operators. Forgive me if this is a dumb question, but my
|manuals don't say very much about it. Thank you.

Some minimal amount of storage overhead must be incurred by the
general memory management schemes.  In the case you describe above,
this overhead comes to 6 bytes.  That's not too bad.  It amounts to a
pointer and a size...

If you want to decrease your overhead below the empirical 6 bytes,
then you must concoct your own memory management scheme.  This is
easiest to do if the objects you want to allocate are all the same
size.  You can overload operator new for that class, and then allocate
large arrays of storage.  Two arrays will do.  One serves as that
actual storage that you will dish out with your overloaded new, and
the other array can act as a bitmap to record whether a cell in your
array is free or not.  This amounts, theoretically, to a one bit
overhead per block.

--
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: pnarayan@cs.tamu.edu (P S Narayan)
Newsgroups: comp.lang.c++
Subject: C++ book
Date: 15 Sep 1992 17:44:22 GMT
Distribution: usa
Organization: Computer Science Department, Texas A&M University



Can any one tell me of a c++ bible, something like the kernighan and ritchie
kind or simpler than that say by Kochan.
I need the name of the book and the author. If you know of a good C++ book
from any of the book clubs kindly let me know. I am a member of the
Newbridge book club. I might as well buy it from them at member price

Thanks
Narayan
pnarayan@cs.tamu.edu
Newsgroups: comp.lang.c++
From: kuiper@prl.philips.nl (Krijn Kuiper 44381)
Subject: Re: Deleting NIHCL Objects
Keywords: virtual destructors 
Organization: none
Date: Fri, 11 Sep 1992 12:30:33 GMT

In article <1992Sep9.110455.17143@etn.ericsson.se> bjs@etn.ericsson.se (Bj|rn S{ter|y 1342) writes:

 > i soon found out that deleting the set though ~Set destructor
 > did not delete the objects in the set. i therefore tried to

thank god ~Set keeps its hands off, suppose you had several
references to one object in different sets!

 > most everything else about NIHCL seems very well designed, and i
 > can accept the fact that deleting the Set not automatically deletes
 > the individual objects, but the non virtual ~Object "feature" surprised
 > me.
 > i am hesitant to modify the NIHCL source code to make the ~Object 
 > is it possible to "fix" (i.e. by just making the ~Object virtual)?

yes, I did and it did not harm and gave no significant performance loss.

Krijn Kuiper
Philips Research Laboratories
Eindhoven - The Netherlands
Newsgroups: comp.lang.c++
From: pjl@sparc10.cs.uiuc.edu (Paul Lucas)
Subject: Re: dynamic arrays of objects
Keywords: arrays, dynamic
Organization: University of Illinois at Urbana-Champaign
Distribution: usa
Date: Tue, 15 Sep 1992 03:02:23 GMT

In <5515@naucse.cse.nau.edu> jdc@naucse.cse.nau.edu (John Campbell) writes:

>What I want to do is increase an array of pointers to objects so that 
>I can write an ``append'' member function.  I've read question 35 of 
>the FAQ and so I know that realloc is not a good thing.  However, I 
>want to simply increase the size of the array of pointers and (as a
>C programmer) it seems to me that this should be easy to do.

[ ...stuff elided... ]

>Is this normally done by "renewing" the array itself and replacing it
>with array[count+1] in the append routine?  Otherwise, in Scott Meyers'
>book (Effective C++) he shows using a linked list to solve a problem 
>similiar to this.  I could implment a linked list, but it seems nasty--do 
>I next have to overload the array operator ``[]'' simply to add a slot 
>to an otherwise fully functional array.  And how do I effeciently traverse 
>a linked list to reach the "i'th" element, anyway?

*****>	There's no such thing as a free lunch.  Even if realloc were to
	exist, it would have to do the work (you don't want to).

	For simple things: alloc a bigger array, copy old into new,
	delete old.  Period.  Often, it's done in "chunks" so you don't
	have to keep alloc'ing every time you add just _one_ element.

	See also:

		Thomas Cargil.  "A Dynamic Vector is Harder Than It
			Looks."  C++ Report, vol. 4, no. 5, June 1992.
			pp. 47-50.
-- 
	- Paul J. Lucas				University of Illinois	
	  AT&T Bell Laboratories		at Urbana-Champaign
	  Naperville, IL			pjl@cs.uiuc.edu
From: taylor@foraker.tivoli.com (Eric Taylor)
Newsgroups: comp.lang.c++
Subject: Bogus warning message
Date: 8 Sep 92 21:56:34 GMT
Organization: TIVOLI Systems, Inc.

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
From: djds@goanna.cs.rmit.oz.au (DARYL JOHN D'SOUZA)
Newsgroups: comp.lang.c++
Subject: operator overloading
Keywords: pointer usage
Date: 14 Sep 92 05:00:45 GMT
Organization: Comp Sci, RMIT, Melbourne, Australia

I am seeking clarification of the following note in the Stroustrup text
(bottom of page 236):

	"Pointers can not be used because it is not possible to redefine 
	the meaning of an operator when applied to a pointer."

I tried the following program which seems to compile and run, in contradiction
to this statement.  I'm sure the problem lies with my misinterpretation of
Stroustrup's note, but either way, would someone please elaborate.  Here is
my C++ program:


//--------program begin
#include <iostream.h>
#include <iomanip.h>

class nat { // natural number class
	int val;
public:
	nat(int i) { val = i; }
	nat(const nat & n) { val = n.val; }
	nat & operator = (const nat & n) { val = n.val; return *this; }
	nat & operator = (int i) { val = i; return *this; }
	nat operator +(const nat * & r) { return nat(val + r->val); }
	int access() { return val; }
};

main()
{
	nat i = 10, j = 20, *p = &j;

	i = i + p;
	cout << i.access() << ' ' << j.access() << ' ' << (*p).access() << endl;
	i = *p + &i;
	cout << i.access() << ' ' << j.access() << ' ' << (*p).access() << endl;
	*p = i + &j;
	cout << i.access() << ' ' << j.access() << ' ' << (*p).access() << endl;
}
//---------program end

Thanks.

Daryl D'Souza
-- 
Dept. of Computer Science, RMIT, GPO Box 2476V Melbourne 3000, Australia. 
email: djds@rmit.edu.au. Tel: +61 3 660 2927/2348; Fax: +61 3 662 1617.
Newsgroups: comp.lang.c++
From: etxolpn@beppe.ericsson.se (Ola Persson)
Subject: Help on delete
Organization: Ericsson
Date: Thu, 10 Sep 1992 09:29:07 GMT

Hello world!

Suppose

	char *temp = new char[10];

will 
	delete temp;

do as freeing or is

	delete []temp;

necessary ?

Regs from Sweden!

Ola
From: rmartin@thor.Rational.COM (Bob Martin)
Newsgroups: comp.lang.c++
Subject: Re: Help on delete
Date: 11 Sep 92 00:15:58 GMT

etxolpn@beppe.ericsson.se (Ola Persson) writes:

|Hello world!

|Suppose

|	char *temp = new char[10];

|will 
|	delete temp;

|do as freeing or is

|	delete []temp;

|necessary ?

If delete temp; works, it is not because the language allows it.  The
proper form is delete [] temp;. 


--
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: Neelakantan Sundaresan <nsundare@silver.ucs.indiana.edu>
Subject: friend classes of template classes
Organization: Indiana University
Date: Mon, 14 Sep 1992 22:23:51 GMT
X-Mailer: ELM [version 2.3 PL11]


I am having problems compiling a friend class of a template class when
it accesses a member of the friend class accesses a type defined in the
template of which it is a friend. 
----
     template <class T> class U
     {
        private:
           enum error { i, j, k};
           friend class W;
        public:....
     };
     class W
     {
        int error_fn(U::error);
                     ^^^ point where the compiler needs an instantiation
                            of the template.
     };
Even if I give it an instantiation of the template as U<X> (where X is
some defined class), the compiler screams saying size unknown.
-----

Any hints as to what I am doing wrong?
thanks
Neel.
PS: This is with the CC translator.
     

Newsgroups: comp.lang.c++
From: int401a@mdw045.cc.monash.edu.au (Mr D. Vladicic)
Subject: help in C++ 
Organization: Monash University
Date: Wed, 9 Sep 1992 01:23:50 GMT


Iam a final year computer science student currently working on a
c++ project.  The problem i have is that when i make my program
i get the following message

ld:
Undefined:
_$_4User
collect: /usr/bin/ld returned 1 exit status
*** Error code 1


i have linked the program to all its components e.g User 
the program  will compile except it wont give executable
permission to the final object code.

	When i change mode the program will complete all its tasks 
	till it finishes at which point it gives a segmentation fault

WHAT I  would like to KNOW is what causes the error is it the User constructor
or is it something else
		example of the constructor is provided below

		User::User(String& user_name,String& password)
{
       	
        person= new Personal;  // simple struct 
        if (!Check_password(user_name, password))
                {
                        cout<<" you bombed" << endl;
                        exit(1);
                        //give an error message and abort
                        
                }


          Finances=new Financial(user_name);     
          History=new Tipping_History(user_name);
}
			
		any assistance would be greatly appreciated

				int401a@mdw045.cc.monash.edu.au
				Dragan Vladicic

From: int401a@mdw045.cc.monash.edu.au (Mr D. Vladicic)
Newsgroups: gnu.g++.help
Distribution: world
Followup-To: 
Organization: Monash University
Subject: C++ construtor problem  
Keywords: 


Iam a final year computer science student currently working on a
c++ project.  The problem i have is that when i make my program
i get the following message

ld:
Undefined:
_$_4User
collect: /usr/bin/ld returned 1 exit status
*** Error code 1


i have linked the program to all its components e.g User 
the program  will compile except it wont give executable
permission to the final object code.

	When i change mode the program will complete all its tasks 
	till it finishes at which point it gives a segmentation fault

WHAT I  would like to KNOW is what causes the error is it the User constructor
or is it something else
		example of the constructor is provided below

		User::User(String& user_name,String& password)
{
       	
        person= new Personal;  // simple struct 
        if (!Check_password(user_name, password))
                {
                        cout<<" you bombed" << endl;
                        exit(1);
                        //give an error message and abort
                        
                }


          Finances=new Financial(user_name);     
          History=new Tipping_History(user_name);
}
			
		any assistance would be greatly appreciated

				int401a@mdw045.cc.monash.edu.au
				Dragan Vladicic

From: int401a@mdw045.cc.monash.edu.au (Mr D. Vladicic)