HDTenEightyP/NetNews huggingface dataset:
From: pauljo@microsoft.com (Paul Johns)
Subject: Re: Newing a pointer to a pointer
Date: 30 Dec 92 03:52:00 GMT
Organization: Microsoft Corp., Redmond, Washington, USA

A pointer to a pointer is not the same as a pointer to
an array in C++ (nor C).

Your design needs at least two memory allocations:  one for
the data to be stored, and one for the array of pointers
to the beginning of each row.

lspace would point to the array of pointers (one for each
row); each pointer in the array would point to the beginning
of its row.  The rows could be allocated in one block, or
they could each be allocated separately.  They can also be
of different lengths.

In any case, it's your responsibility to:

1.  Allocate the array of pointers.

2.  Allocate the data memory.

3.  Set each pointer in the array to point to the appropriate
	memory.

K & R has a lot more on this.  

If you're willing to live with a fixed row length, you can 
use a design very similar to yours in which lspace is a 
pointer to an array:

	const int LCOL = ???;	// at file scope

	list (*lspace)[LCOL];

If you think about what the computer has to do to index
into a two-dimensional array stored in one-dimensional
memory, it becomes more clear why this is so.

Or you can write a dynamic matrix class that would do what
you want.

// Paul Johns
From: jamshid@ut-emx.uucp (Jamshid Afshar)
Newsgroups: comp.lang.c++
Subject: Re: How to call C++ functions in a C program?
Summary: RTFFAQ
Date: 21 Dec 92 23:48:23 GMT
Reply-To: jamshid@emx.utexas.edu
Organization: The University of Texas at Austin; Austin, Texas

>>>I know we can call C functions inside a C++ program. Is there a way to
>>>call a C++ function inside a C program?
>> Basically, you can't.
>I'm not sure how standard it is, but with at least some compilers [...]

Remember Frequently Asked Questions Lists should be read by *anyone*
posting to a newsgroup, whether it's a question or an answer.  This
topic is handled *thoroughly* in "PART16 -- Linkage-to /
relationship-with C".  The FAQL is available by anonymous ftp at
sun.soe.clarkson.edu in the file pub/C++/FAQ.

Q105: How can I call a C function `f()' from C++ code?
Q106: How can I create a C++ function `f()' that is callable by my C code?
Q107: Why's the linker giving errors for C/C++ fns being called from C++/C fns?
Q108: How can I pass an object of a C++ class to/from a C function?
Q109: Can my C function access data in an object of a C++ class?
Q110: Why do I feel like I'm `further from the machine' in C++ as opposed to C?

Jamshid Afshar
jamshid@emx.utexas.edu
Newsgroups: comp.lang.c++
From: gs4t@virginia.edu (Gnanasekaran Swaminathan)
Subject: Re: Matrix Addition  Was Re: Complex Addition.
Keywords: operator, memory leak
Organization: University of Virginia
Date: Tue, 22 Dec 1992 19:44:14 GMT

ren@function.mps.ohio-state.edu (Liming Ren) writes:
: >class Matrix {
: >	struct MatRep {
: >		int	ref;
: >		int  	rows, cols;
: >		double*	d;
: >	
: >		MatRep (int r, int c)
: >		: ref(1), rows(r), cols(c), d(new double[rows*cols]) {}
: >		~MatRep () { delete [] d; }
: >	}* rep;
: >public:
: >	Matrix (int r, int c): rep(new MatRep(r,c)) {}
: >	Matrix (const Matrix& m): rep (m.rep) { ++rep->ref; }
: >	~Matrix () { if (--rep->ref == 0) delete rep; }
: >
: >	double	operator () (int i, int j) { return rep->d[i*rep->rows+j]; }
: >	Matrix& operator =  (const Matrix& m) {
: >		if (this != &m) {
: >			this->Matrix::~Matrix (); // self destruct
: >			rep = m.rep; ++rep->ref;
: >		}
: >		return *this;
: >	}
: >
: >	friend Matrix  operator + (const Matrix& a, const Matrix& b);
: >};
: >
: >// note the return by value here
: >Matrix operator + (const Matrix& a, const Matrix& b)
: >{
: >	Matrix sum (a.rep->rows, a.rep->cols);
: >	for (int i=0; i < sum.rep->rows * sum.rep->cols;  i++)
: >		sum.rep->d[i] = a.rep->d[i] + b.rep->d[i];
: >	return sum;
: >}
:  I am new to c++, my questions are:

There are two very well written introductory books on
C++ that new users may want to read:

B. Stroustrup, "The C++ Programming Language, 2nd Edition,"
Reading, MA: Addison-Wesley, 1991.

S. Lippman, "The C++ Primer, 2nd Edition,"
Reading, MA: Addison-Wesley, 1992.

: (1) In the destructor ~Matrix(), what happens to the memory pointed by d? It is my understanding
: that the memory pointed by d should also be deleted explicitly. Although I am not quite sure.

[As an aside please keep your lines less than 72 chars
 long in the future. Thanks.]

~Matrix deletes its rep iff no other Matrix object is
referring to it. When rep is deleted, the destructor
~MatRep takes care of deleting the memory pointed to by d.

: 
: (2)In the operator + definition,  sum.ref is initialized to 1. In order to be alive after exiting
: the function, the sum.ref at least should be 2. Where is the ref incremented exactly and by which
: function?

sum will be destructed when operator + goes out of scope.
But, before that when operator + returns, sum's rep->ref
is incremented by the copy constructor Matrix(const Matrix&)
and hence, sum's rep will not be deleted when sum is destructed.

Newsgroups: comp.lang.c++
From: warren@nscf.org (L3 Warren)
Subject: Re: Borlands next C++ release?
Organization: National Science Center Foundation
Date: Wed, 30 Dec 1992 21:41:29 GMT

ericm@ims.com (Eric Martinson) writes:

>I saw an add for Turbo Pascal with Objects on the back cover of a magazine.
>I personally could care less about Pascal Object Oriented Programming (POOP)
>but I was interested in the claim of a DPMI extender included with the package.
>Has anyone heard if Borland International plans on including such an extension
>with the next release of Borland C++? Any rumors and/or suggested availability
>dates?

If memory has not failed me, they included the Phar Lapp dos extender with
the 3.1 release of BC++. Quite some time ago.

Warren.

Newsgroups: comp.lang.c++
From: hansen@pegasus.att.com (Tony L. Hansen)
Subject: Re: Is there a lint++?
Organization: AT&T
Date: Wed, 30 Dec 1992 21:28:08 GMT
Summary: yes, there are some things a lint++ can do
Keywords: c++, lint

From: pickerig@eee.bham.ac.uk (Guy Pickering)

<< This may seem peculiar, but is there such a thing as lint++ to check C++
<< code?  Or does lint have a switch to do the same? 

< lint is a tool to highlight problems in C code. It was designed to
< suppliment pre-ANSI C compilers, because they would quite happily pass bad
< code (mainly in the area of parameter mis-matches).

< Your C++ compiler should not need lint. lint (as far as I know) offers
< nothing your C++ compiler will provide. Anything that is not caught at
< compile time will be caught at link time bacause of type safe linkage.

There are a number of things which a lint++ could check for. Some of these
are C++-specific and others are shared with C.

Scott Meyers (author of Effective C++) wrote a paper that appeared in the
UseNIX C++ Conference a year or so ago that talked about several things that
are C++-specific. An example would be checking to make certain that a class
which has virtual functions also has a virtual destructor.

There are also various things which lint checks in C that would be useful in
C++. These are things which require extra-lingual information that lint
pragma's can provide information on. An example is checking the types of
parameters of variable-length argument functions (such as sprintf() and
execl()). C++ has no way of specifying information on what's supposed to be
provided in the "..." portion of the function invocation.

Take a look at a modern lint, such as the UNIX System V Release 4 lint, and
look at the types of things checked for and the pragmas that are supported.
Not all of these capabilities are associated with the type system.

Here's another example:

	function/variable X is external and could be static

There's no way that a C++ compiler is going to tell you that information,
but the SVR4 lint will.

					Tony Hansen
			    hansen@pegasus.att.com, tony@attmail.com
				att!pegasus!hansen, attmail!tony

Newsgroups: comp.lang.c++
From: bear@kestrel.fsl.noaa.gov (Bear Giles)
Subject: Re: Weird problem under Sun/C++
Organization: Forecast Systems Labs, NOAA, Boulder, CO USA
Date: Wed, 30 Dec 1992 23:58:30 GMT

We finally found the problem.

She was specifying the library with -lsage, thinking that the linker would
use the copy of libsage.a in her current directory.

Instead if was using an old copy in ~/lib which she had forgotten about.
The procedure TupleFile::find() had recently changed (the fifth argument
of the fourth argument (which was a pointer to a function) had just dropped
a 'const' keyword).

Therefore, her source and the _local_ library had matching member functions.
Extracting the object file from the local library worked (although it caused
'multiply defined' error messages), but replacing the file in the local
library didn't solve any problems.

We only found the problem after replacing -lsage with libsage.a -- which
suddenly worked!  After switching back to -lsage and digging in the CC
man page we found the linker flag which causes it to display the actual
libraries used and discovered the old copy of the library.


Bear Giles
bear@fsl.noaa.gov
Newsgroups: comp.lang.c++
From: pauljo@microsoft.com (Paul Johns)
Subject: Re: Complexity in the eyes...V2.0
Date: 23 Dec 92 20:35:56 GMT
Organization: Microsoft Corp.:  Redmond, Washington, USA

In article <1992Dec17.042207.8150@tagsys.com> andrew@tagsys.com wrote:
> 
> Almost a month ago, I tried to start a new thread on the topic
> of "complexity".  I assume that everyone agrees that a goal of
> software engineering should be the reduction of complexity.  But
> what I have recently seen is that the metrics by which complexity
> is measured appear to be very subjective.

An important question to ask is "Complexity as viewed by whom?"

Solutions which are simple and elegant to our users (both end users
and users of our class libraries) are often a pain to implement.
And sometimes expensive, too.

But if a lot of people are going to use your product, the time
spent making it easy for them to use gets repaid MANY times over
when it's easier to use.

There's also a power vs. simplicity issue.  What's the good tradeoff?

In your case, I think that the additional power provided by your
technique is well worth the additional memory and time requirements,
as well as the development time.

I guess I'm arguing that "It's too complex!" is NOT a valid reason for
choosing one implementation over another, while "It's a memory hog!",
"It's a CPU hog!", "It'd take too long to implement!", and "No one
would be able to use it reliably!" might well be valid reasons for 
choosing a less-powerful alternative.

// Paul Johns
Newsgroups: comp.lang.c++
From: jimad@microsoft.com (Jim Adcock)
Subject: Re: Special-purpose-heap-managers - references, FTP?
Date: 24 Dec 92 18:35:11 GMT
Organization: Microsoft Corporation

In article <rmartin.725043829@thor> rmartin@thor.Rational.COM (Bob Martin) writes:
|I have made use of special purpose heap managers many times.  They are
|easy to construct, and much faster than the general purpose
|(new/delete, malloc/free) type allocators.  How much your application
|will benefit from using them depends a lot on how much allocation you
|perform.

Agreed.  The only disadvantage is that they are special purpose not general
purpose.  Perhaps the right approach is to introduce special purpose allocators
into a program where and when profiling indicates the need.

Newsgroups: comp.lang.c++
From:  stas@itco.msk.su (Stas Strizhakov)
Subject: Re: New try: Access to private constructor for building a private static member
Date: Thu, 31 Dec 1992 06:52:14 GMT
Reply-To: stas@itco.msk.su
Organization: I.T. Co., Moscow, Russia.

In message <GIROD.92Dec23081920@node_262d6.tele.nokia.fi>
Subject: [NEWS] New try: Access to private constructor for building a private static member
girod@tele.nokia.fi (Marc Girod) writes:

>class A {
>  private:
>    A();
>    static A a;
>};
...
>Are my compilers correct in refusing me the access to private
>constructors, to build a private static member?

Yes, it is correct, because private member functions, including constructors,
can't be used out from class instance because of unvisibility. It is
ideology of OOP. If you try to create private static member with private
constructor, compiler will consider this as try to access private member
function out from instance during startup code.
So you should make the constructor with "public" access declaration.

I think so.
--

					Regards,
								Stas.
???????????????????????????????????????????????????????????????????????????????
						There's so many different worlds
						So many different suns
Stas K. Strizhakov				I.T.Co				Programmer
phone	: (7-095)262-4381		fax 	: (7-095)924-3775
e-mail	: stas@itco.msk.su




Newsgroups: comp.lang.c++,sci.math
From: claird@NeoSoft.com (Cameron Laird)
Subject: Re: IS C++ a language for the "average programmer"
Organization: NeoSoft Communications Services -- (713) 684-5900
Date: Tue, 29 Dec 1992 16:27:19 GMT

In article <1992Dec28.145347.18572@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
>In article <1992Dec28.053645.17136@nuscc.nus.sg> tim@iss.nus.sg (Tim Poston) writes:
>>Anybody who thinks they can prove that every complex polynomial
>>has at least one root without using analysis
>>(the study of the kind of proofs that apply to calculus),
>>see me after class.
>>
>
>	But this is silly, since R is constructed by analysis.
>Given R, and the fact that every positive real has a root in R, 
Does "every positive real has a root in R"
give us something that "every polyn of odd
degree over R has a zero in R" does not?  I
have to strain to make sense of the first
of these quoted propositions.
>and every polyn of odd degree over R has a zero in R, 
>the Fundamental Theorem of *Algebra* (all polyns over C can be reduced
>to linear factors) follows by algebra.
			.
			.
			.
Please, tell us more.  My best understanding
is that it's considerably more subtle than
you appear to be claiming.  In fact, do you
have a proof 
1.  of the reducibility of quadratics
    over the complexes, which
2.  is free of analysis other than the
    solvability of odd-degree polynomials?
The ones I know are rather delicate.
-- 

Cameron Laird
claird@Neosoft.com (claird%Neosoft.com@uunet.uu.net)	+1 713 267 7966
claird@litwin.com (claird%litwin.com@uunet.uu.net)  	+1 713 996 8546
Newsgroups: comp.lang.c++
From: jss@lucid.com (Jerry Schwarz)
Subject: Re: Help with floating point I/O (well, really O)
Reply-To: jss@lucid.com (Jerry Schwarz)
Organization: Lucid, Inc.
Date: Thu, 24 Dec 92 02:27:57 GMT

In article <1992Dec22.200420.1734@brtph560.bnr.ca>, markham@brtph597.bnr.ca (Andrew Markham P205) writes:

|>             cout << setprecision(3) << setw(6) << .1 << endl;
...

|> Prints the following output:
...
|>            0.1
...
|> How do I get it to print the following?
...
|>          0.100
...

Do 
	cout.setf(ios::fixed) 

before inserting the numbers

  -- Jerry Schwarz
Newsgroups: comp.lang.c++
From: steve@taumet.com (Steve Clamage)
Subject: Re: template disappointments ... (suggestions?)
Organization: TauMetric Corporation
Date: Fri, 1 Jan 1993 17:08:12 GMT

erc@netcom.com (Eric Smith) writes:

>In article <1992Dec30.173230.22878@taumet.com> steve@taumet.com (Steve Clamage) writes:
>>In a template instantiation, the 'int' argument might be any expression,
>>including one containing right shifts.  If you try to allow what appears
>>to be a right shift to be two closing ">" instead, you wind up with
>>nondeterministic lexing/parsing, ambiguous grammars, or context-sensitive

>How is >> different from > in that respect?  a>b is a perfectly valid
>int expression.

The '>' is always a '>' token.  The proposal was that sometimes '>>' is
a '>>' token and sometimes it is two '>' tokens.  The compiler would have
to decide which interpretation to use.  One interpretation might wind up
being unparseable only after an arbitrary number of additional tokens.

Suppose there are several sets of '>>' in a template expression.  Each
one is a branch point for additional possible parses.  The compiler has to
verify that exactly one of a set of interpretations leads to a valid parse.

A whole new kind of parsing is therefore required just to allow
programmers to omit a blank between consecutive closing template brackets.

It isn't impossible to have a language like this.  The question, as
always, is whether the additional compiler complexity and other
disadavantages are outweighed by the advantages.  The decision in C
and C++ has always been to choose context-free lexical analysis and
the "maximum munch" lexical rule.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Newsgroups: comp.lang.c++
From: rmartin@thor.Rational.COM (Bob Martin)
Subject: Re: Special-purpose-heap-managers - references, FTP?
Organization: Rational
Date: Tue, 22 Dec 1992 17:03:49 GMT

sabroe@daimi.aau.dk (Morten Sabroe Mortensen) writes:

|Could anyone, -who have tried-, tell, what kind of experiences they have with 
|special-purpose-heap-managers like 'Pool', in what kind of program, with what 
|kind of result/speed-up? 

I have made use of special purpose heap managers many times.  They are
easy to construct, and much faster than the general purpose
(new/delete, malloc/free) type allocators.  How much your application
will benefit from using them depends a lot on how much allocation you
perform.


--
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: val@news.ccutah.edu (Val Kartchner)
Subject: Re: IS C++ a language for the "average programmer"
Organization: University of Utah Computer Center
X-Newsreader: Tin 1.1 PL3
Date: Wed, 23 Dec 92 20:27:37 GMT

rmartin@thor.Rational.COM (Bob Martin) writes:
: sam4628@zeus.tamu.edu writes:
: |In article <rmartin.724431509@thor>, rmartin@thor.Rational.COM (Bob Martin) writes...
: |..
: |> 
: |>This is not a new idea.  Calculus is more complex than algebra.  Yet,
: |>once learned, it alows a whole new ream of concepts to be conveniently
: |>expressed.  
: 
: |Yes, but does OO _really_ allow you to tackle a more complex problem?
: |Or does it just allow you a new "notation" which is conveniently adapted
: |to the more complex type of problems?  
: 
: No, it really allows you to tackle a more complex problem.  This is
: because of the paradigm has more expressive power than procedural
: programming does.  
: 
: |I've never heard of a programming
: |goal which absolutely required OO to achieve it -- however, there are
: |a large number of math problems which algebra just cannot solve, no
: |matter how you manipulate it (assuming, of course, that you don't start
: |making simplifying assumptions/approximations).
: 
: I don't want to push the analogy too far.  ...

I see no reason to not push the analogy any further.

As I understand mathematics, there are thirteen basic assumptions.  (I
forget the proper name of these.)  These assumptions are such as "1 = 1",
"1 + 1 = 2", etc..  From these thirteen basic assumptions, the rest of
mathematics is derived.

You can compare these 13 assumptions to the seven basic operations necessary
for any processor.  These operations are binary add, unary minus, load, store,
etc..  (I would appreciate a list of these as well as a reference of where
I could actually get a research paper on this.  Thanks in advance.)  The
rest of the operations are built up of these.

The simple mathematical operations that we take for granted are simply
derivations of the 13 assumptions.  Algebra is an extension of those.
Calculus and geometry are an extensions of algebra.  The advantage of one
method over another is that you have different conceptual levels and
notational syntaxes (and symboligies) which represent them.

Object-orientedness doesn't allow you to solve problems that couldn't be
solved otherwise.  It does, however, allow a different way of addressing
the problems that you are given to solve.

			-=:[ VAL ]:=-
--
|================== #include <disclaimer.h> ==================///=============|
| "AMIGA: The computer for the creative mind" (tm) Commodore /// Weber State  |
| "Macintosh: The computer for the rest of us"(tm) Apple \\\///   University  |
|== "I think, therefore I AMiga" -- val@csulx.weber.edu ==\///= Ogden UT USA =|
Newsgroups: comp.lang.c++
From: reagle@umbc8.umbc.edu (Mr. Joseph Reagle; MEYERHOFF (U))
Subject: Do I need to worry about what the compiler will do?
Organization: University of Maryland, Baltimore County Campus
Date: Wed, 23 Dec 1992 20:32:58 GMT

	I've been considering writing a C++ linked list, and then
develop a class queue and class stack based on the linked list.
Within the book I have been reading (Turbo C/C++ (with Borland) the Complete
Reference)) there is a simple example of a linked list using a
template.
	I unfortunately don't have the book with me right now,
(waiting for pop to take me home, and the books are packed, but I can
type in the example once I get home), but essentially it is a simple
linked list using a template so it can take any: 
	data_t data
	linked_list *next,
then within the class public functions such as add are in there, the
add I believes looks something like this:
	add (linked_list *node) {node->next = this;}

and within the main body, a pointer to an object name "last" is passed
in.
	Now to the real question, each node in this linked list is
made by passing in a every char in the alphabet in as part of the
constructer: (p is a pointer to the object list as well.)

while (i < 26) loop
	Make P point to a new iniatized object (node) [constructer used]
	p->add (last)
	i++

	_So_ my question is, since each node is actually an object,
with it's own data, all created when the constructor
is called, and dynamic iniatilization is used to pass in a char, does
each one of those nodes (objects)  also contain, or cause the compiler
to create it's own function.  (So for however many instances of objects from
the same class, there are an equal amount of 'functions' in the
executable code, all exactly similar in what they do.)
	I would assume not, but if not, does it only 'compile' one
instance of the function?
	If you don't understand what I've said here, don't worry, when
I get home, I'll post the source code that led me to the question.
And I'm sure it's a very simple answer, for if the compile were to
duplicate similar (exactly) functions that may reside in 2 or more
objects the binary image would be much larger than it has to be.

					Joe
Newsgroups: comp.lang.c++
From: xorian@solomon.technet.sg (Xorian Technologies)
Subject: Re: Wanted C++, LEX++, YACC++ etc.
X-Newsreader: TIN [version 1.1 PL8]
Date: Mon, 28 Dec 1992 02:06:50 GMT

Peter Lim (plim@hpsgwr.sgp.hp.com) wrote:

: 	[03]	Implementation of LEX and YACC useable with C++
: 		(LEX++ & YACC++ ???).

Our company have develop a compiler-generator which amoung others is
capable of building a C++ parser with all the conflicts resovled.  We
have also build a C++ front-end (parser with semantic checks) which
will be ready in a month time, this will include Tamplates as well
as Exception Handling.

LADE is written in C++ and generate C++ code as well.  If anyone is 
interest send me an email.

K G Loh
Xorian Technologies Pte Ltd
389A Balestier Road
Singapore 1232
Republic of Singapore

Tel: (65) 255-7151
Fax: (65) 253-7709
email: xorian@solomon.technet.sg
Newsgroups: comp.lang.c++