HDTenEightyP/NetNews huggingface dataset:
From: gs4t@virginia.edu (Gnanasekaran Swaminathan)
Newsgroups: comp.lang.c++
Subject: Re: Const and Reference
Date: 9 Oct 92 16:55:29 GMT
Reply-To: gs4t@virginia.edu (Gnanasekaran Swaminathan)
Organization: University of Virginia

mittle@siena.watson.ibm.com (Josh Mittleman) writes:
: The correct output is '+'.  A reference is an alias, so any change to a is
: also a change to b.  

I disagree. The correct output is '-' and a reference to a
const T is not an alias as I can understand from ARM.

: > Also ARM p. 154 says, "... if the reference is to a const an object
: > of type will be created and initialized with the initializer."
: > Hence, if you modify variable a above it would not get reflected
: > in reference b.
: 
: No, you are mis-reading the text: It refers to a reference to a const, not
: a const reference.  The examples which follow illustrate the point:

On p. 153, ARM defines what T& means:
	'A variable declared to be a T&, that is "reference
	 to type T"...'
Therefore, const T& should be reference to a const T

:   double d = 1.0;          // normal initialization
:   const double& rcd = d;   // rcd refers to d

Also the above quote from p. 154 of ARM does not say anything
about the constness of the initializer.

So, if I understand the quote from p. 154 correctly, 
rcd should refer to a temporary initialized with d.

:   const char a = '-'
:   char &b = a;              // warning: const initializer: temporary used to
:                             // initialize reference 

This is an error. p. 155 of ARM says, "A reference to
a plain T can be initialized *only* with a plain T."

I request the ANSI committee to clarify the language as the above
passages from ARM lends itself to different interpretation
by different people. Thanks.

-Sekar
			     
Newsgroups: comp.lang.c++
From: steve@taumet.com (Steve Clamage)
Subject: Re: streams
Organization: TauMetric Corporation
Date: Wed, 14 Oct 1992 17:45:41 GMT

mdk34398@uxa.cso.uiuc.edu (Mike Krupicka) writes:

>I am writing some code where I would like to be able to read in either from
>stdin or from a file. What I want to know is how do you initialize the stream,
>and pass it to a common var. I tried something like the following and had
>problems because the code was local only to the if statement.

>main(){
>.
>.
>if (stdflag)
>	ostream& fin = cin;
>else
>	ofstream& fin("test.in");

(I assume you meant "istream" and "ifstream".)

1.  Use a pointer instead of a reference.

	istream *istr = 0;

	main()
	{
	    ...
	    if( ... )
		istr = &cin;
	    else
		istr = ifstream("file");
	    ...
	}
	foo()
	{
	    ...
	    *istr >> x >> y >> z;
	    ...
	}

2.  Instead of a global variable, pass a reference from main() to
    a function which initiates the work.

	void process(istream&);

	main()
	{
	    ...
	    if( ... )
		process(cin);
	    else {
		ifsteam istr("file");
		process(istr);
	    }
	    ...
	}

    Function process() starts out with a reference to an input stream,
    and can pass it along to other functions which may need it.


3.  You can play some games using an istream_withassign class, but
    this technique is a bit complicated.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Vice Chair, ANSI C++ Committee, X3J16
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c++
Subject: requirement for overloaded operator must have class
Date: 13 Oct 92 21:36:08 GMT
Organization: negligable

I would like some explanation of the reasoning behind the rule
that an overloaded operator must take at least one parameter
of as "class" type.

In particular, it would be real convenient to be able to
overload the (char *) conversion operator for an enum to print the "symbolic" 
value instead of being forced to be an int.

e.g.:

--- start of example code ---

enum NMErr {        // NameMgr Errors defined as a type
    E_NOT_ERR=0,
    E_BAD_SITE_ADDR,    // bad site address for command
    E_SITE_NOT_FOUND,   // no site @ addr
    E_NEXT_NOT_FOUND,   // no next site AFTER given address
	...
	};

const char *aszNMEmsgs[] = {
    //- General errors
    "(not an error)",          
    "BAD_SITE_ADDR",            // bad site address for command
    "SITE_NOT_FOUND",           // no site @ addr
    "NEXT_NOT_FOUND",           // no next site AFTER given address
	...
	};

// note: I may not have syntax right here
const char *&operator char *(NMErr &v)		
{
	return aszNMEmsgs[v];
}

--- end of example code ---

(The "translation array" and operator code would be in a library .C
file, the enum in a .h file)

I *can* overload the << operator, but that is only because it
takes a class as it's first argument:
	ostream& operator<<(ostream &s, NMErr &ev);

so it's more or less a coincidence that this works....


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Blasting, bursting, billowing forth with	|
the power of ten billion butterfly sneezes,	|	-Richard Hartman	
Man, with his flaming fire,			|	hartman@uLogic.COM
has conquered the wayword breezes.		|
From: rwk@silver.sbi.com (Richard W. Kreutzer Consultant)
Newsgroups: comp.lang.c++
Subject: Re: My objects are too big - why?
Date: 11 Oct 92 21:19:18 GMT
	<DOUG.92Oct9093158@monet.ads.com> <1992Oct9.175014.15457@cs.brown.edu>
Distribution: comp
Organization: Integra Software Corporation
In-reply-to: sdm@cs.brown.edu's message of 9 Oct 92 17:50:14 GMT

In article <1992Oct9.175014.15457@cs.brown.edu> sdm@cs.brown.edu (Scott Meyers) writes:
Path: pivot-sts!sbi!internet!psinntp!psinntp!uunet!brunix!brunix!sdm
   From: sdm@cs.brown.edu (Scott Meyers)
   Newsgroups: comp.lang.c++
   Date: 9 Oct 92 17:50:14 GMT
   References: <1b23cuINN26n@early-bird.think.com> <1992Oct09.141039.18062@watson.ibm.com> <DOUG.92Oct9093158@monet.ads.com>
   Sender: news@cs.brown.edu
   Distribution: comp
   Organization: Brown University Department of Computer Science
   Lines: 24

   In article <DOUG.92Oct9093158@monet.ads.com> doug@monet.ads.com (Doug Morgan) writes:
   | C++ guarantees all objects have nonzero size, therefore the nonzero
   | sizeof(Base).  I've never been able to completely follow the ARM's
   | statements about subobjects, but I suspect they somehow imply that
   | memory space for derived classes can't be reused for data members if
   | already set aside by a base class.  This and (probable) fullword
   | alignment requirements give the sizeof(Derived) = 8.

   This is contrary to my understanding of the situation.  I was under the
   impression that a compiler is allowed to play games such that

			 sizeof(Derived) = sizeof(Base)

   if either is empty.  (Actually, I thought that due to the strange rules
   governing layout of class members, this might even be true if neither class
   is empty.)  For the particular example being bandied about, I thought that
   it was possible for sizeof(Derived) = sizeof(int) because the padding
   character added to the Base class could be omitted for Derived objects.  Is
   this not true?

   Scott

   -------------------------------------------------------------------------------
   What do you say to a convicted felon in Providence?  "Hello, Mr. Mayor."

I see no reason why this could not be true.  However, I know of no C++
compiler which implements it.  I have two questions: 

For the standards folks:

	Could an implementation "special case" this "hidden member variable"
	when inheriting from an empty base class (when the derived class has
	its own data) without violating existing standards?

And for the C++ compiler implementors:

	How difficult would it be to do this?

--

--
        Richard W. (Dick) Kreutzer
Net:    rwk@quark.sbi.com				CIS:	70702,2174
Voice:  +1(801)571-2446					FAX:	+1(801)571-2448
Mail:   Integra Software Corp.; 1378 Jasmine Avenue; Sandy, UT 84092 (USA)
Newsgroups: comp.lang.c++
From: sem@isi.itfs.nsk.su (Tarasov Eugene)
Subject: Help: C++ and C grammar required
Date: Tue, 13 Oct 1992 03:15:07 GMT
Reply-To: sem@isi.itfs.nsk.su
Organization: Institute of Informatics Systems, Novosibirsk

Help!
   I need BNF description of C++, ANSI C, and KR C as well. Where can I
get it from, or at least yacc definitions?
   GNU C++ yacc definitions  unacceptable  beacuse  they  contact  with
BISON too much and too closely.
   Is there pure context-free C++ grammar at all?

Thanks,
  Eugene Tarasov
  sem@isi.itfs.nsk.su
From: Ilan.Berkner@f1.n100.z60.wlink.nl (Ilan Berkner)
Newsgroups: comp.lang.c++
Subject: Turbo C++ / Heap sort algorithm
Date: Tue, 13 Oct 1992 05:33:06 -0100

Organization: George Washington University

I'm trying to develop an abstract Q system on Turbo C++.
One of the requirements for the system is that a possible implementation
for a Q would be a heap sort of either ascending or descending order.
(Using a tree, not an array.)
I know what a heap sort is and how it works. How ever, I am fairly new
to the C++ environment.
If anyone has implemented such an algorithm or has somesort of sample code
please e-mail directly.
Your help would be appreciated.
Thanks,
	ilan@seas.gwu.edu


Newsgroups: comp.lang.c++
From: c7821027@csie.nctu.edu.tw (Shih-Hao Liu)
Subject: Re: Const and Reference
Organization: National Chiao Tung University
X-Newsreader: TIN [version 1.1 PL6]
Date: Fri, 9 Oct 1992 03:47:20 GMT


Sorry, I have make some mistake in posting this question.
The prog should be modified as following.

: #include <stdio.h>
: main()
: {
:     char a = '-';
:     const char &b = a;
: 
      a = '+';
      printf("%c\n", b);
: }
: 
: What output should we excepted?
: The CC compiler on Sun yield '+', but gcc give a '-'. Which correct?
: 
: Shih-Hao Liu
: c7821027@csie.nctu.edu.tw
: 
:
From: pjl@sparc10.cs.uiuc.edu (Paul Lucas)
Subject: Re: virtual destructors
Organization: University of Illinois at Urbana-Champaign
Distribution: usa
Date: Mon, 12 Oct 1992 13:51:37 GMT

In <1992Oct11.170052.26134@aplcen.apl.jhu.edu> ded@aplcen.apl.jhu.edu (nod sivad) writes:

>If one defines the following classes:

>class A {
>public:
>	~A()			{}
>	virtual void func()	{}
>};
>class B : public A {
>public:
>	~B()		{}
>	void func()	{}
>};

>Then runs the following code:

>	A* ptr = new B;
>	ptr->func();	// thanks to polymorphism, B::func() is called
>	delete ptr; 	// DAMNIT, A::~A() is called, not B::~B()

>It is natural to have a base class pointer point to several derived
>class instances.  Thus a "polygon" pointer can point to "squares,"
>"rectangles," "pentagons", etc.  However, when one wants to 
>delete this instance, it seems as if you have to cast the object
>to get the correct destructor.  This requires knowledge of the
>actual derived class involved.  I can think of ways to do this,
>but they all smell kludgy.

>I guess what I want is a virtual destructor.  Is there a way to invoke 
>destructors of derived types with a base class pointer (without casting)? 

*****>	Yes.  Declare the destructor virtual.  RTFM.
-- 
	- Paul J. Lucas				University of Illinois	
	  AT&T Bell Laboratories		at Urbana-Champaign
	  Naperville, IL			pjl@cs.uiuc.edu
From: pena@niksula.hut.fi (Olli-Matti Penttinen)
Newsgroups: comp.lang.c++
Subject: Re: Pointer to C++ method in C
Date: 12 Oct 92 18:10:15 GMT
Distribution: comp.lang.c++
Organization: Helsinki University of Technology, Finland

In article <stefans.718036989@bauv106> stefans@bauv106.bauv.unibw-muenchen.de (Stefan Schwarz) writes:


   >I need to call a C++ method from within a C module by using a
   >C-pointer-to-function. I do that by passing "this" as first (implicit) 
   >parameter. This may not be very portable.

   Try calling a static member function by passing the this-pointer
   as regular argument.

And give it C linkage:

extern "C" void static_function(void *object,....);

   Something like;

   void static_function (void *object,....)
   {
	   my_object *obj = (my_object *) object;
	   obj->member_function (...);
   }


   Stefan

==pena

--
Olli-Matti Penttinen <pena@niksula.cs.hut.fi>
Lehdesniityntie 3 F 91
00340 HELSINKI                     "When in doubt, use brute force."
tel. + 358 0 1399 0110                -- Ken Thompson
Xref: sparky comp.lang.c++:14929 comp.lang.c:14915
From: stella@glg.ucs.dec.com (STella)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Documentation Survey for DEC's Compilers
Date: 13 Oct 92 04:14:25 GMT
Reply-To: stella@glg.ucs.dec.com (STella)
Followup-To: poster
Organization: Digital Equipment Corporation

The documentation professionals who write both hardcopy and online information
in support of Digital's compilers would like your opinion.  The purpose is to 
improve how we provide product information to programmers who use our compilers.

We value your opinion and are eager to hear from you.  We will acknowledge all
respondents and send a compilation of the survey's results to all who respond.

Please return this survey to stella@glg.ucs.dec.com.


Thanks and Regards,

John E O'Neil, Documentation Supervisor	oneil@casdoc.enet.dec.com 
Mike Etzel, Fortran 
Barbara Bishop, Ada
Ron Johnson, Pascal
Neil Savage, C++
John Paolillo, C


		QUESTIONNAIRE
                -------------

What programming languages (and what percentage of time are they used?)
does your organization use? 

__ Ada  __ C  __ Cobol  __ C++  __ Fortran  __ Pascal  __ Other(please specify) 


How much mixed-language programming do you do, and what languages do you use?


Do you port programs from one system to another? If so, which systems?


In support of your programming activities, how much do your programmers
depend on finding reference and tutorial information from HARDCOPY books? 

____ 100% of time  ____ 75% of time  ____ 50% of time  ____  25% of time
____  Other


How much do your programmers depend on finding reference or tutorial 
information from ELECTRONIC or ONLINE information sources?  

____ 100% of time  ____ 75% of time  ____ 50% of time  ____ 25% of time
____ Other


What is the biggest improvement that can be made in providing reference
and tutorial information in either online or hardcopy format for compilers?


In 1993, what percent of programmers at your site do you expect will be
primarily using:

___ % Workstations  ___ % PCs connected to window servers  ___ % PCs standalone
___ % Character cell terminals


There are certain ways to find information, such as the table of contents,
the index, alphabetical listings, and so on.  However, all of these put
the burden of finding information on the end user.  What can you suggest
that makes finding information easier and faster?


What software vendor stands out as having superior quality, accuracy and
usability in the reference and tutorial information it provides with the
programming languages it sells?  

Would you care to comment on what is important, and what to avoid, in the
software industry? For example, is Windows NT from Microsoft an 
important platform for the future?  Is an immediate and heavy investment in 
object-oriented programming a must?


Can you envision multimedia information in support of compilers?  For example, 
simply click to see a full motion video lecture on the exact nature of a
particular error message.  Or click again to get an animated overview of a
compiler's new features.


Can you comment on any of the reference or tutorial information that
accompanies any of Digital's compilers?
From: Christian.Franke@f1.n100.z60.wlink.nl (Christian Franke)
Newsgroups: comp.lang.c++
Subject: Another MSC 7 problem
Date: Tue, 13 Oct 1992 09:52:38 -0100

Organization: Rechnerbetrieb Informatik  /  RWTH Aachen

nikki@trmphrst.demon.co.uk (Nikki Locke) writes:

>The following program will not compile under MSC 7 (it's O.K. under 
>Zortech and Borland). Is it legal C++ ?
>-----------------------------------------------------------
>struct Base {
>	Base();
>	};
>
>struct Command { 
>	int (Base::*f)(); 
>	Command(const Command &);
>	};
>
>Command::Command(const Command &d)
>: f(d.f)
>{
>}

>class Base1 {
>	};
>
>class Base2 {
>    };
>
>class Derived : public Base1, public Base2 {
>	};
>
>class Command {
>	int (Derived::*f)(void); 
>	Derived *to; 
>	virtual int doit();
>	};
>
>int Command::doit()
>{ 
>	return (to && f) ? (to->*f)() : 0; 
>}

I checked both with AT&T CFront 2.1 and with GNU C 2.2.2 on a SPARC
and it compiles with no complaint.


>Is anyone interested in these ?

Sure!

>Is there a better place for them ?

I think "comp.os.{msdos|ms-windows}.programmer"

>Needless to say, I do contact MS support when I find them, but I have the 
>feeling it's not doing me any good (they are hardly likely to rush me a 
>bug fix, are they ?). I wish they would accept bug reports via e-mail, 
>it's so much easier than hanging on the phone.

I called MS Munich some weeks ago, they told me that they are
not allowed to give away their E-Mail address.

Regards,

	Christian Franke

	Aachen University of Technology
	Informatik I
	Ahornstrasse 55
	W-5100 Aachen
	Germany
	Tel.: +49.241.80-21111
	E-Mail: franke@informatik.rwth-aachen.de

Newsgroups: comp.lang.c++
From: pete@genghis.borland.com (Pete Becker)
Subject: Re: Proposal: Preconditions and PostConditions in C++
Originator: pete@genghis.borland.com
Organization: Borland International
Date: Sat, 10 Oct 1992 16:55:52 GMT

In article <23852@alice.att.com> bs@alice.att.com (Bjarne Stroustrup) writes:
>
> > C++ doesn't have
> > any way of differentiating different kinds of inheritance nor does
> > Eiffel (I think).
>
>Actually, C++ does: public derivation implies a subtype relationship,
>private derivation doesn't.
>

	I wouldn't want to see this idiom become part of the language
definition.  It is very useful today, as we struggle to understand type
relationships, but there are situations where it does not apply, and I suspect
that as we develop a more thorough understanding of these issues it will become
less and less helpful.
	-- Pete
From: maybee@pogo.wv.tek.com (Joe Maybee)
Newsgroups: comp.lang.c++
Subject: Replacing the Borland Memory Manager...how?
Date: 9 Oct 92 21:46:02 GMT
Reply-To: maybee@pogo.wv.tek.com
Distribution: usa
Organization: Tektronix, Inc., Wilsonville,  OR.

Well, this is probably a problem that has been solved many times in this
newsgroup, but here goes anyhow...

I'm trying to replace the Borland memory manager (C++, 3.0) so that I
can use a real time kernel and have my applications people still use
``malloc'' and associated goodies the way they would ordinarily.

HOWEVER, for some reason, I get gibberish when I instantiate an object
after the first `new' and `delete' operations.  The `this' pointer that
I end up with inside the object appears to be kosher (i.e. the one that
was allocated by my revised `malloc').  It strikes me as odd that even
though the `this' pointer is correct, the base classes do not appear
to be properly initializing the object that `this' points to.  

By any chance has anyone else out there seen this problem?  What is the
solution?

I suspect the default `new' operator that invokes `malloc' may be taking
advantage for some register states that a generic `C' or `C++' routine
may not know or care about (such as ES is already set to point to the
allocated memory header, or some such stuff.)

Rather than try to trace all the way through, I thought I'd ask.

Please use e-mail to repond to this, 'cause I'm sure this is old stuff to
most of the veterans of this group.

Thanks!

---Joe Maybee.

P.S.  I'm using the FAR model, and I've selected the option that ES = DS NEVER.
      This is a DOS application, not a Windows application.  Thanks.
Newsgroups: comp.lang.c++
From: Netwind@world.std.com (Michael P Wilson)
Subject: C++ editor and asst TC++ probs.
Summary: I'm writing an editor class(es) in Turbo C++.  HHEELLPP!
Keywords: TC++ Editor source classlib wanted
Organization: The World Public Access UNIX, Brookline, MA
Date: Sun, 11 Oct 1992 02:28:48 GMT

  Greetings, I wonder if someone out there would help me.  I'm new to C++ (1 1/2 years) and I've recently been called upon to write a full screen editor class
in Turbo C++.  All windowing and cursor manipulations are in other libraries.  Does anyone have any hints on how I should structure this?  I've been programming in Pascal for over 10 years, and 80X86 assembler for a little less than that.  But I'm having some problems thinking like C++, as it were.
	If someone could point me to an ftp site with some code to grind through, I'd be very appreciative.

Also, I'm having some newfound problems compiling large programs in TC++.  The main compilation goes quite smoothly, although when I hit linking, I'm assaulted with "function __main( )not defined in module C01.asm" along with several other errors of the same ilk.  This happens consistantly with the same source, but smaller stuff is not affected.  

Thanks for your help.

    Michael Wilson


Newsgroups: comp.lang.c++
From: jmvt@prl.dec.com (Jean-Manuel Van Thong)
Subject: C++ Books - US price ?
Keywords: books
Organization: Digital Equipment Corporation - Paris Research Laboratory
Date: Wed, 7 Oct 1992 09:44:25 GMT


Hi,

Could someone give me the US price of the two following books:

	The C++ Programming Language , 2nd Edition
	Bjarne Stroustroup
	Addison Wesley, 1992

	Effective C++ - 50 specifics ways to improve your
	programs and designs
	Scott Meyers
	Addison Wesley, Professional Computing Series, 1992


Thanks,

JM-
Newsgroups: comp.lang.c++
From: danyang@bbc.Stanford.EDU (Dan Yang)
Subject: static in Templates for AT&T 3.0
Organization: Stanford University
Distribution: su
Date: Fri, 16 Oct 92 18:28:20 GMT

Help! 

I have some trouble to use AT&T 3.0 for static in template
class. Following is the code:


//========================================
#include <stdio.h>
#include <string.h>

template <class T>
class A
{
 public:
  A(int j) { i = j; }
  T s;
  static int i;
};

main()
{
  A<char *> a(10);
  printf("a.i = %d\n", a.i);
  return 0;
}
//==========================================

I got the following error message:

CC  test.c:
cc  -L/usr/local/lib   test.c -lC
CC  A__pt__3_Pc.c:
cc  -c  -Dc_plusplus=1 -D__cplusplus=1 -DBSD -I/usr/local/include/CC A__pt__3_Pc.c
CC[ptlink]: unresolveable template symbols are:
	A<char*>::i
CC[ptlink] fatal error: template symbols cannot be resolved



-- 
Dan Yang

work phone:    5-6240
home phone:    408-945-9743

Newsgroups: bnr.lang.c++,comp.lang.c++
From: crlstu4@bnr.ca (Goetz von Escher)
Subject: Is pointer in my address space?
Keywords: process address memory pointer
Organization: Bell-Northern Research, Ottawa, Ontario, CANADA
Date: Fri, 9 Oct 92 16:01:54 GMT


Hi there!

Is there a way to find out if a pointer is a valid pointer in C/C++?
Or in other words: If I want to read a value in memory, how do I
know wether I can read the value at this address without causing
an exception (bus error, segmentation fault and that stuff)?

Anything?
Goetz
From: le@maja.teknikum.uu.se (Lars Ericsson)
Newsgroups: comp.lang.c++
Subject: Email address to Zortech Tech Supp
Date: 7 Oct 1992 16:04:30 GMT
Organization: Uppsala University, Dept. of Technology, Circuits and Systems
NNTP-Posting-Host: gimble.teknikum.uu.se

I have encountered some problems with Zortech C++ v3.0r4 and would like to
get in touch with their Technical Support group. Does anyone know if they
have an email address?
I can make zorlibx crash and think they might like to know how,
in case they don't know it already.