HDTenEightyP/NetNews huggingface dataset:
From: barmar@think.com (Barry Margolin)
Newsgroups: comp.lang.c++
Subject: Re: Can a class inquire about subclass data members by name?
Date: 30 Sep 1992 16:00:35 GMT
Organization: Thinking Machines Corporation, Cambridge MA, USA
NNTP-Posting-Host: telecaster.think.com

In article <1992Sep30.145631.26176@wl.com> agrafiot@wl.com (Dimitris Agrafiotis) writes:
>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 ?

The answer to all of these is "no".  C++ provides no built-in facilities
for inspection of the class structure.  As with ordinary C (and most other
languages), names only exist at compile time.

Actually, you may be able to do what you want in implementation-dependent
ways, by using linkage and debugging information in the object file.  This
isn't reliable, since such information is often removed when a program is
built for final installation.
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

barmar@think.com          {uunet,harvard}!think!barmar
Newsgroups: comp.lang.c++,comp.std.c++
From: frank@Cookie.secapl.com (Frank Adams)
Subject: Re: Conceptual Constness
Date: Mon, 28 Sep 1992 21:40:48 GMT
Organization: Security APL, Inc.
Keywords: const, const member, lazy

In article <BRENNAN.92Sep28124052@yosemite.hal.com> brennan@hal.com (Dave Brennan) writes:
>I write a lot of C++ classes that are optimized to not do anything any
>sooner than they have to.  Here's a contrived example:
>
>[example deleted]
>
>The list of Foo objects doesn't exist until a user of a FooList tries to
>access an element of the list.  Conceptually accessing an element is an
>operation that I would be like to be able to perform on a const object
>because conceptually it does not modify the FooList.
>
>My complaint is that C++ doesn't provide a way to indicate this conceputal
>"constness."  [ugly work-arounds deleted]

One other ugly work-around is to have the body of the class contain only
a pointer to the *real* contents, which you can then modify to your heart's
content.

This indicates another aspect of the problem: a "const" declaration doesn't
force "conceptual constness".  At best (for the reader of a program) it is a
hint that the object is not going to be changed.

>Has this problem ever been addressed or pondered before by anyone else?
>Is there a better way around the problem? Is this a problem worthy of a
><*gasp*> language extension?

This is not a simple problem.  The discussion above only scratched the
surface.  Adding a language extension to deal with this case will only raise
a host of new problems, each (in the new context) at least as urgent as
this.  IMO, it is better to leave good enough alone; get around the problem
by not declaring pointers/references to such classes const.  Leave this kind
of problem for new langauges, which may take a quite different approach to
the whole problem.

Actually, I think that adding "const" to the language was a mistake of just
this sort; this is one amongst the many problems it has given rise to.  This
is 20/20 hindsight, of course.  If I had been the language designer when the
suggestion was made to add it to the language, I would probably have agreed.
From: mnm@hpcuhe.cup.hp.com (Michey Mehta)
Date: Mon, 28 Sep 1992 22:36:15 GMT
Subject: Re: templates and const parameters
Organization: Hewlett Packard, Cupertino
Newsgroups: comp.lang.c++

When you substitute "int *" for T in the template
	void set (const T a) { _a = a;}
you get 
	void set (int * const a) { _a = a;}

(you do not get "void set (const int * a) { _a = a;}")

>main()
>{
>	A<int*> a;
>	const int *x = new int(1);
>	a.set(x);
>}

This means that you cannot declare "x" as "const int *x"; instead it
should be declared "int *x". Or, instantiate the template by using
"A<const int*> a;".
From: rgp@mpd.tandem.com (Ramon Pantin)
Newsgroups: comp.lang.c++
Subject: Re: can != be used in compound if
Date: 1 Oct 92 03:29:31 GMT
Organization: Tandem Computers, Micro-Products Division

In article <1992Sep30.161650.21488@news.acns.nwu.edu> cnhasan@casbah.acns.nwu.edu (Nirmal Hasan) writes:
>In <1992Sep28.195425.26253@julian.uwo.ca> operator@julian.uwo.ca (Operator) writes:
>>if (rnum != number_set[1] && rnum != number_set[2] && rnum != number_set[3])
>
>>is this if statement correct because the computer has been hanging on it
>
>  if ((rnum != number_set[1]) && (rnum != number_set[2]) && (rnum !=
>number_set[3]))
>
>In other words, the problem may be because you did not use parenthesis around
>each of the conditions.

Why don't you try this?
	if ((((rnum) != ((number_set)[(1)])) &&
	     ((rnum) != ((number_set)[(2)]))) &&
	     ((rnum) != ((number_set)[(3)])))

Have you folks ever written a single line of C code?
The orignal code is perfectly correct, the extra parentesis are
useless.  If your compiler hangs, then go get a real compiler.
In any case, please read ANY C programming book.

Ramon Pantin
Newsgroups: comp.lang.c++
From:  michael@ovsen.msk.su (Michael Y. McAlcin)
Subject: Re: DGROUP exceeds 64K
Date: Sat, 26 Sep 1992 12:20:36 GMT
Reply-To: michael@ovsen.msk.su
Organization: Ovsen Ltd.

>
> void junk_fn( void )
> {
>    junk_stuff();
>
>    junk_class* junk_array[] =
>    {
>       new junk_class( p1, p2, "HERE IS JUNK STRING 1" ),
>       new junk_class( p1, p2, "HERE IS JUNK STRING 2" ),
>       .
>       .
>       .
>       new junk_class( p1, p2, "HERE IS JUNK STRING n" ),
>    }
>
>    more_junk_stuff();
> }
>

Rewrite like this:

char far  ptr1[] = "Here is junk string 1";              or
char huge ptr1[] = "Here is junk string 1";

        ...
{
    new junk_class(p1, p2, ptr1);
}

Newsgroups: comp.lang.c++,cs.help
From: igor@cs.columbia.edu (Igor Pankevich)
Subject: yacc in c++?
Keywords: yacc, bison, c++
Organization: Columbia University Department of Computer Science
Date: Mon, 28 Sep 1992 21:43:25 GMT

I am a student (forgive me if this is a FAQ, I couldn't find the
answer at my site.)  I need to write a yacc grammar that will work
with my c++ program.  Where can I find a version of yacc to do this?
/igor
From: ernst@sinix.UUCP (Reiner Ernst)
Newsgroups: comp.lang.c++
Subject: Re: comp.lang.c++.src ?
Date: 30 Sep 92 14:46:27 GMT
Organization: SNI AG Muenchen, STO XS

Yes.
------------------------------------------------------------------------------
S I E M E N S  Reiner Ernst               P.O.Box 83 09 51
-------------  SNI STO XS 324		  D-8000 Munich 83
N I X D O R F  Phone: (..89) 636 - 46455  UUNET:    ernst%sinix@germany.eu.net
					  Internet: Reiner.Ernst@sto.mchp.sni.de
From: jtaylor@dseg.ti.com (Jeff Taylor)
Newsgroups: comp.lang.c++
Subject: Borland Cust Ctls Dialog Box as Main Window
Summary: How do you assign an icon to a BWCC Dialog Box as the main window?
Keywords: BWCC, Borland
Date: 1 Oct 92 13:32:21 GMT
Organization: Texas Instruments, Incorporated

Hi folks,

	I've been trying for a couple of days now to assign an icon from a 
resource file to a Borland Dialog Box of class "bordlg" under MS-Windows 3.1.
According to the Borland C++ 3.0 online doc "BWCCAPI.RW" there is a way to 
define your own derivative dialog class for use as an application's main 
window, but I've tried the instructions and variants to no avail...

	Has anyone performed this successfully? If so, could you sent me 
examples so I can figure out what I don't understand.

	Thanks,

	Jeff: JTAYLOR@MK1501.DSEG.TI.COM
From: herbach@informix.com (Martin Herbach)
Newsgroups: comp.lang.c++
Subject: Static Initialization in DLLs?
Date: 6 Oct 92 19:52:42 GMT
Organization: Informix Software, Inc.

Having a problem with MS C++.  Since DLL's don't have a main(),
how do you get the static initializers called in a DLL?  Do you
explicitly call something in the libentry routine?  I can't find
any explicit references in the documentation.  Thanks in advance.
From: gbluhm@galapagos.East.Sun.COM (Gerald Bluhm - Sun USOPS IR)
Newsgroups: comp.lang.c++
Subject: Reassigning this.
Date: 5 Oct 1992 21:08:50 GMT
Organization: Sun Microsystems
Distribution: world
Reply-To: gbluhm@galapagos.East.Sun.COM
NNTP-Posting-Host: galapagos.east.sun.com

   I've been slowly going through the "C++ Primer", 2nd Edition, by
Lippman, and I have a question regarding the example on p.237 which
demonstrates in the member function Screen::reSize(int, int, char) how
you can replace an invoking object with a new object by overwriting
*this.

   In this example, a new Screen object is created with new, and *this
is reassigned to the the new object, leaving the old one dangling.
(There's a "delete screen" statement in there, but screen is just a
char * member of the Screen class, not a Screen instance.)

   Is this considered good practice?

   Is it possible to first assign another pointer to the invoking 
object before reassigning *this, and then you delete the invoking 
object:

..
	Screen *oldps = *this;
	*this = *ps;	// replace Screen object
	delete oldps;
	return *this;
}

   Or, am I missing something?

Newsgroups: comp.lang.c++,comp.std.c++,gnu.g++
From: leonard@cs.utwente.nl (Leonard Thierry)
Subject: C++ Parser Class wanted
Keywords: parsing, parser, grammar, language
Organization: University of Twente, Dept. of Computer Science
Date: Mon, 5 Oct 1992 12:36:05 GMT


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++ |
=======================================================================
From: ameesh@lsil.com (Ameesh Desai)
Newsgroups: comp.lang.c++
Subject: Re: Persistance Problem Solved by Memory-Mappe
Date: 30 Sep 92 22:35:27 GMT
Reply-To: ameesh@lsil.com
Organization: LSI Logic Corporation


In article 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?
>-- 
>Dave Feustel N9MYI <feustel@netcom.com>
> 
>[.sig on vacation]

Yes it can be and in fact its being used by ObjectStore (an ODBMS) as its 
underlying architecture.

You need to do some work with making the data re-locatable (i.e. swizzelling ptrs).

Under Sun's NFS, the swap to a mapped file is quite slow (we found upto 10x when a 
gateway is involved) thus this could really impact the performance of your app. 
You could use local disk to store the mapped files - this would get around the
NFS problem.

Ameesh

---
______________________________     o__            
| _   /|     Ameesh Desai     \    ,>/_                              
| \`O.o'     LSI Logic Corp.   \__(_)`(_)_              email: ameesh@lsil.com
| =(_|_)=    MS E192, 1501 McCarthy Blvd. \             fax  : (408) 433-6802
|____U_______Milpitas, CA 95035____________\____________voice: (408) 433-4097 
Newsgroups: comp.lang.c++
From: stefans@bauv106.bauv.unibw-muenchen.de (Stefan Schwarz)
Subject: Re: Pointer to C++ method in C
Organization: Universitaet der Bundeswehr Muenchen (Germany)
Distribution: comp.lang.c++
Date: Fri, 2 Oct 1992 14:43:09 GMT

maffeis@ifi.unizh.ch (Silvano Maffeis) writes:

>Hello!

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

>What is a more portable way of achieving the same effect?
>Will the standard C++ parameter passing convention consider
>such problems?

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

Something like;

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

This should be absolutely portable.

Stefan
-- 
________________________________________________________________________________
Stefan Schwarz                            University of the armed forces, Munich
Laboratory for graphical data processing  W-8014 Neubiberg, FRG
--------------------------------------------------------------------------------
Newsgroups: comp.lang.c++,comp.std.c++
From: frank@Cookie.secapl.com (Frank Adams)
Subject: Re: The concept of templates considered ill designed
Date: Mon, 05 Oct 1992 17:26:02 GMT
Organization: Security APL, Inc.

In article <BvM0DE.EA7@watcgl.uwaterloo.ca> pfbertra@watcgl.uwaterloo.ca (Philippe F. Bertrand) writes:
>In article <1992Oct2.153826.12051@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
>It would be nice if templates could have some sort of base class derivation
>rules.  Ie instead of < class T > have <class Foo T> which restricts T to be
>a class publicly derived from Foo.

If something like this is adopted, I think a better syntax would be:

<class T : Foo>

similar to the notation for inheritance.  It would be nice to permit:

<class T : Foo, Bar, int>

meaning class T could be a subclass of Foo or of Bar, or could be type int.
Unfortunately, it is difficult to tell this comma from one introducing a new
parameter.
From: jbn@lulea.trab.se (Johan Bengtsson)
Newsgroups: comp.lang.c++
Subject: Re: RTTI in Bjarne Stroustrups book (long)
Date: 30 Sep 92 14:05:01 GMT
Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
X-Newsreader: Tin 1.1 PL4

I wrote:
: 
: mi@starlab.UUCP (Michael Hoennig) writes:
: : Summary: This long article brings up a subtile bug in an existing
: : 		implementation of RTTI (Run Time Type Identification),
: : 		shows a new implementation and the effectiveness of
: : 		RTTI.
: : 
: : In spite of effect the incomplete implementation of RTTI
: : suggested in Bjarne Stroustrup's book 'The C++ programming language'
: : (2nd Ed, 1992) isn't there a subtile bug in it?
: : 
: : Assuming the following class structure:
: : 
: :     class Base <---- class Intermediate <---- class Derived
: : 
: : And now I implement RTTI in Base and Intermediate but not in Derived.
: : At least I do this:
: : 
: :     Base *pBase = new Intermediate;
: :     Derived *pDerived = ptr_cast( Derived, pBase );
: : 
: : I will get pDerived allways pointing to something but it will never
: : become zero!
: 
: Use a global function, Derived_info() instead of a static member function
: Derived::info().  Using a bit of macro hackery (pasting), you should
: be able to automate this just as easily (declare Derived_info() as a friend
: function).
: 
: This does pollute the global name space with a global function
: for each class, but should be harmless, since the function name
: is prefixed with the class name, which must be unique.

Note that this approach is unusable for class templates,
since there is no way to generate a unique global function
name for each template instantiation.

Any better ideas?
-- 
--------------------------------------------------------------------------
| Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden  |
| Johan.Bengtsson@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490  |
--------------------------------------------------------------------------
From: theoretj@Software.Mitel.COM (Jean-Francois Theoret)
Newsgroups: comp.lang.c++
Subject: Turbo Vision's redraw()
Date: 30 Sep 92 20:04:58 GMT
Organization: Mitel. Kanata (Ontario). Canada.



Has anyone had any experience with Turbo Vision's view redrawing
funcion?  Mine have no effect whatsoever.  Do you have to change
the state of a flag so TView::redraw() will have an effect on a
specific window?

I would also need a good Turbo Vision Reference Book (apart from 
Borland's original...) if it exists.  Thanks in advance.

--
Jean-Francois Theoret		theoretj@Software.Mitel.COM     |\_____
Mitel Corp.			Phone: (613) 592-2122 x3718     | O o /
350 Legget Dr.			                               =(_____)=
Kanata, ONT, CANADA K2K 1X3                                        U
Newsgroups: comp.lang.c++,comp.std.c++
From: pkturner@world.std.com (Prescott K Turner)
Subject: Re: Conceptual Constness
Keywords: const
Organization: The World Public Access UNIX, Brookline, MA
Date: Tue, 29 Sep 1992 02:25:17 GMT



In article <1992Sep28.214048.117424@Cookie.secapl.com> frank@Cookie.secapl.com (Frank Adams) writes:
> In article <BRENNAN.92Sep28124052@yosemite.hal.com> brennan@hal.com (Dave Brennan) writes:
> >My complaint is that C++ doesn't provide a way to indicate this conceputal
> >"constness."  [ugly work-arounds deleted]
> 
> One other ugly work-around is to have the body of the class contain only
> a pointer to the *real* contents, which you can then modify to your heart's
> content.

Another workaround is to have two classes, the conceptually const class
being the base of the regular class.

> >Has this problem ever been addressed or pondered before by anyone else?
> >Is there a better way around the problem? Is this a problem worthy of a
> ><*gasp*> language extension?

There is a proposal before the C++ standards committee, informally called
"~const" for its syntactic characteristic, which addresses the problem.
--
Prescott K. Turner, Jr.
Liant Software Corp. (developers of LPI languages)
959 Concord St., Framingham, MA 01701 USA    (508) 872-8700
UUCP: uunet!lpi!pkt                          Internet: pkt@lpi.liant.com
From: djd@csg.cs.reading.ac.uk (David J Dawkins)
Newsgroups: comp.lang.c++
Subject: Re: Persistance Problem Solved by Memory-Mapped Files?
Date: 30 Sep 92 07:18:27 GMT
Organization: University of Reading

barmar@think.com (Barry Margolin) writes:

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

>Not really.  Memory-mapped files raise the problem of making object
 ^^^^^^^^^^

    Have you tried?

>representation independent of the address space in which the object
>resides.  Pointers between objects have to be replaced with offsets from
>the base of the file.  ....

    Not if you use MMAP_FIXED (on a Sun). A big constraint, I know.

>   ...              .  Linkage to virtual member functions would have to be
>done differently; if the vtbl lives in the shared memory then the function
>pointers will have to be done in an process-independent manner, but if the
>vtbl lives in the per-process memory then the vptr will have to be
>process-independent.  You can't assume that functions will be in the same
>place in each process, since an object library may be linked into many
>different programs.

    Only if you _use_ virtual functions.

    All extremely valid points, but a bit defeatist in attitude :-)
    Maybe you can't have everything you want, but you sure can compromise.

-dave


-- 
djd@uk.ac.reading.cs.csug
djd@uk.ac.reading.cs.csg
davidd@integ.uucp
Newsgroups: comp.lang.c++
From: stephen@mont.cs.missouri.edu (Stephen Montgomery-Smith)
Subject: Good book on C++
Organization: University of Missouri
Date: 28 Sep 92 23:06:22 GMT

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.

I am sorry if this question is a FAQ.  If it is, could some kind soul post
the FAQ to me?

Stephen
From: morss@ssd.kodak.com (Charlie Morss)
Newsgroups: comp.lang.c++
Subject: How to do record locking?
Date: 2 Oct 92 15:13:51 GMT
Distribution: usa
Organization: Eastman Kodak


I hope this is not a FAQ (at least I could not find it in the FAQ!).

- I have not been able to figure out how to do record locking using
  the fstream class (or which ever stream class is appropriate).

I need to do the "normal" type of locking, start at location X and 
lock for N bytes. I also need to be able to lock the whole file. 


Any pointers would be great, I'm really in a bind.

Thanks in advance,

Charlie 

** if you can, please email me, I don't always get a chance
** to stay up with the "News", I summarize after I get responses!

-- 
-----------------------------------------------------------------
Charlie Morss                               Voice: (716) 726-5461
morss@eksignal.kodak.com                      Fax: (716) 726-4850 
-----------------------------------------------------------------
Newsgroups: comp.lang.c++
From: pcm@cs.brown.edu (Peter C. McCluskey)
Subject: Re: What cout has done to my code?
Organization: Brown Computer Science Dept.
Distribution: usa
Date: Sun, 27 Sep 1992 21:15:40 GMT

In article <1a2hr1INN1jr@miles.mps.ohio-state.edu>, ren@miles.mps.ohio-state.edu (Liming Ren) writes:
|> 	I am working on code handling bitvector. I can't figure out what 
|> cout has done to cause the following: If I comment out the line
|> 
|>  cout<<wordWidth<<" "<<sizeof(*(tmp+i))<<endl;
|> 
|> I get result as 
|> 	 4294967295
|> 	 875706676	
...
|> #define WORDSIZE 32
|> typedef unsigned int *BitVec;
|> 
|> class BitVector{
|>  public:
|>   BitVector(int=WORDSIZE, int=0);
|>   ~BitVector(){delete [] bv;};
|>   BitVector operator~() const;  
|>   //~ return the complement of the bitvector;
|>   show();
|>  private:
|>   BitVec bv;
|>   unsigned short size; //bit length of the bitvector;
|>   short wordWidth; // wordlength of the bitvector;
|>   };
|> 
|> BitVector BitVector::operator~() const
|> {
|>   //bitwise negation operation;
|>   BitVector result(size, 0);
|>   BitVec tmp=result.bv;
|>   for(int i=0; i<wordWidth; i++)
|>     {
|>       *(tmp+i)=~(*(bv+i));
|>     }
|>   cout<<wordWidth<<" "<<sizeof(*(tmp+i))<<endl;
|>   //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^;
|>   //*************the above line causes the problem**********
|>   return result;
|> }
...
|> main()
|> {
|>   BitVector bb(32, 1);
|>   BitVector bc=~bb;
               ^^^
Here you have an implicit call to the BitVector copy constructor.
Since you haven't defined one, a default copy constructor is used.
It copies the pointer BitVec bv, but doesn't copy the array that
bv points to. To avoid random results, define a copy constructor
explicitly and have it create and initialze a new array for bv.

----------------------------------------------------------------------
  \\ !Vote Libertarian! \\ Peter McCluskey  \\ !Vote Libertarian! \\
  // Vote Marrou in `92 // pcm@cs.brown.edu // Vote Marrou in `92 //
----------------------------------------------------------------------
Newsgroups: comp.lang.c++
From: pat@frumious.uucp (Patrick Smith)
Subject: Re: Persistance Problem Solved by Memory-Mapped Files?
Date: Thu, 1 Oct 1992 05:24:53 GMT
Reply-To: uunet.ca!frumious!pat
Organization: None

rmartin@thor.Rational.COM (Bob Martin) writes:
|If the mapped file cannot be mapped into the same address space for
|each process that uses it, then persistent pointers to persistent
|objects will be useless.  This is a big disadvantage since most
|persistence mechanisms need to store the structure of societies of
|objects rather than just the objects themselves.

As someone pointed out in another posting, you can use an offset
from the beginning of the mapped file instead of a pointer.
(Sorry, I forget who made the comment.)

As an slight improvement on this, you could store the offset from the
offset, instead of from the beginning of the mapped file.
That is, to convert an integer offset o to a T*, you would do something
like this:

   T* p = (T*) (((char*)&o) + o);

This way you need one less piece of information to find the indicated
object from the offset.

-- 
Patrick Smith
uunet.ca!frumious!pat
pat%frumious.uucp@uunet.ca