HDTenEightyP/NetNews huggingface dataset:
From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
Subject: Re: classes
Organization: MAXTAL P/L C/- University Computing Centre, Sydney
Date: Wed, 27 Jan 1993 15:04:40 GMT

In article <1jpa7pINNac9@nestroy.wu-wien.ac.at> h8850513@d21.wu-wien.ac.at (Michael Tesar) writes:
>Hello!
>
>I have a problem with my classes matrix and amatrix.
>Class matrix is for simple 
>matrix operations, eg. multiplication
>In this class I have overloaded the operator*
>
>matrix operator*(matrix& mat);
>
>This class is working well and now I wanted to write a new class amatrix
>with all methodes of the matrix class - but I didnt like to change my 
>matrix class. But in this new class I had to overload the operator* again.
>
>amatrix operator*(const double dvalue);
>
>But now I cannot use the multiplication of two amatrix objects.
>
>The only way to solve this problem - I know - is to write the function
>amatrix operator*(amatrix& mat);
>again, but I think this is not C++ like. 

	Why not?
>
>Is there any possibility to avoid this dublication?
>
	If you use a member function, there is no way to
avoid the duplication and there shouldnt be either. After all,
the methods are internally different, you simply must
write a new version.

	If you have some methods like 'set(int i, int j, double v)'
in BOTH matrix classes, you can almost solve the problem, however:

	class AbstractMatrix {
	public:
		virtual void set(int i, int j, double v)=0;
		virtual double get(int i, int j)const=0;
		virtual int dimen()const=0; // assume square matrix
	};

	class matrix : public virtual AbstractMatrix { ... }
	class amatrix : public virtual AbstractMatrix { ... }

	AbstractMatrix& operator*=(AbstractMatrix &a,
		const AbstractMatrix& b)
	{
		assert(a.dimen()==b.dimen()); // run-time check
		const int d=a.dimen();

		double *temp=new double[d*d];

		for ( int i=0; i< d; ++i)
		{
			for( int j=0; j<d; ++j)
			{
				double sum=0;
				for (int k=0; k<d; ++k)
					sum+=a.get(i,k)*b.get(k,j);
				temp[i*d+j]=sum;
			}
		}
		for(i=0; i<d; ++i)
		for(j=0; i<d; ++j)
			a.set(i,j,temp[i*d+j]);
		delete temp;
		return a;
	}
	// warning untested !!

which uses a global function to multiply ANY two matrices 
of equal square dimension together, provided they're
both derived from AbstractMatrix. (Thus they must
have 'get' and 'set' methods, and have 'double' or
equivalent components -- no complex matrices)

Nothing stops you defining more efficient versions for special
cases. (Although the way I've set it up the compiler would need
to know the static types of the arguments to call the special
cases).

However, note that the operation defined is *= and not *.
Bad luck: you cant have an abstract * operation.

-- 
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;------ SCIENTIFIC AND ENGINEERING SOFTWARE ---ph:  2 799 8223 --------
From: schmidt@rz.uni-passau.de (SCHMIDT GUIDO)
Newsgroups: comp.lang.c++
Subject: Re: DOS, BC++, Need, large data memory, how?
Date: Sat, 23 Jan 1993 14:10:12 GMT
Organization: University of Passau - Germany
NNTP-Posting-Host: hiwi170.rz.uni-passau.de

In article <RUNE.93Jan22073636@calypso.nta.no> rune@nta.no (Rune Henning Johansen FBA) writes:


> > I've tried the following program with TCW 3.0 in model SMALL. It works fine.

>Thanks for the program! I didn't know about "farmalloc" before.  But
>my problem is that I'm not able to link my program. (I should have
>specified that, sorry!) When I'm able to run my program, I guess
>"farmalloc" will be very useful in a redefined "new", but until then:
>How can I link my program without getting: "Automatic data segment
>exceeds 64K"?

> - Rune



Hello!

Since you use TCW as far as I understood your questions you can only use
model LARGE as the biggest one. This gives you only 64k for the automatic 
data segment per .cpp file. In the automatic data segment you find (as the
name says) automatic data. I.e. variables which are local to a function and
are not static. See the following example:

	void anyfunction() {
		char largearray[50000]; // <-- automatic data
		...
		largearray[1000] = 'A';
		...
	}

You can get around this by using the heap/farheap with new, malloc or
farmalloc. In the above example:

	void anyfunction() {
		char * largearray;            // <-- takes only 2 or 4 bytes
		largearray = new char[50000]; // 50000 bytes taken from heap
		...
		largearray*[1000] = 'A';      // I'm not quite sure about
		                              // this one
		...
		delete largearray;            // free 50000 bytes from heap
	}

Guido.
--------------------------------------------------------------------
- Guido Schmidt                                                    -
- schmidt@rz.uni-passau.de                                         -
- Universitaet Passau, Germany                                     -
--------------------------------------------------------------------

Xref: sparky comp.lang.c++:20013 comp.object:5087
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c++,comp.object
Subject: Re: HELP : Array of objects of diff classes ??
Date: 27 Jan 93 19:06:26 GMT
Followup-To: comp.lang.c++
Organization: negligable

In article <mcampbel.727881449@eola.cs.ucf.edu> mcampbel@cs.ucf.edu (Mike Campbell ) writes:
|campbell@src.honeywell.com (Terry Campbell) writes:
|
|
|>In article <1993Jan19.112059.2882@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
|
|>>Dear Everybody,
|>>
|>>
|>>	I have a problem related to programming in an object oriented fashion.
|>>	Here`s the problem description :
|>>        There is an object class called Holder. The object holder can hold various
|>>        things : Pencils, Pens, Erasers etc. I`ve declared different classes for
|>>        these things ( class PENCIL, class PEN, class ERASER etc. ). 
|>>
|>>        The user of this program will choose at the runtime what objects to put
|>>        in the holder. The problem is how do i store this information (i.e the
|>>        contents ) in class HOLDER. I cannot create a single array of objects
|>>        because each object is of different class.
|>>	
|
|>I assume that it reasonable to allow Holder to hold any one of these objects
|>because there is some similarity between these objects.  e.g., they are all
|>drawing tools or whatever.  This concept of similarity should be captured by
|>classifiying each of these item classes as subclasses (or specializations) of
|>the common class (e.g., drawing_object - which may be abstract).  Then, the
|>Holder class simply has to be declared to be able to hold objects of type
|>drawing_object.  Then, any instance of PENCIL, PEN, ERASER and any other class
|>derived from drawing_object cam be held by a Holder instance.  Aggregates can
|>hold heterogeneous collections etc.
|
|I've been following this thread with some interest, and I find your reply 
|interesting.  
|
|I agree with your analysis of the problem re: subclasses, however, what if
|you buy/purchase/steal classes from multiple vendors/coworkers/victims ?
|They necessarily will not have a common base class.  (Or is this correctly
|deemed "superclass?")
|
|Borland does this - they have a common base class, "Object", as I recall, and
|all of the storage classes can hold 'objects'.  This allows the storage 
|classes to hold just about anything in their provided class library, as every-
|thing is derived from the 'object' class.
|
|Any ideas/thoughts from anyone on how to handle dissimilar base classes in a
|'holder' class?

This is the primary legimate use of multiple inheritance.

	class Grandfathered : public Object, public ThirdPartyThing
	{
	...
	};

Watch out for member function name conflicts.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
It's not the way that you say it	|
when you do those things to me,		|	-Richard Hartman	
it's more the way you really mean it	|	hartman@uLogic.COM
when you tell me what will be.		|
Newsgroups: comp.lang.c++
From: vinoski@apollo.hp.com (Stephen Vinoski)
Subject: Re: Was: Template Use <sigh>
Date: Fri, 22 Jan 1993 23:45:09 GMT
Organization: Hewlett-Packard Corporation, Chelmsford, MA

In article <81348@hydra.gatech.EDU> mhopper@cerl.gatech.edu (Michael A. Hopper) writes:
>In article <1jp50dINNk34@rs6000.bham.ac.uk> pickerig@eee.bham.ac.uk (Guy Pickering) writes:
>->Anyway, my problem in more detail is this: I have three directories
>->which contain the following:
>->
>->  1/ The .C and .H files defining the template class LookupTable.
>->  2/ The .C and .H files of an algorithm which uses LookupTable<unsigned
>->     char>
>->  3/ A main.C which binds the whole lot together, but does not itself
>->     use LookupTable<unsigned char>
>->
>->The problem is that at link time, no template instantiation takes
>->place and then the real linker complains about all my member functions
>->of LookupTable<unsigned char> being unresolved.
>->
>->There are unresolved symbols, yet the instantiator doesn't do anything
>->about them.
>->
>->What am I doing wrong??? Any ideas?
>->
>->Guy. 
>
>Put ALL of your template code in header (.h) files.  Do not put template
>code (member functions) in .c files.  In other words, get rid of loopuptable.c
>(or whatever you called it).
>
>This worked for me.

It may work, but it is unnecessary with cfront 3.0.X.  We have several
very large systems under development here that utilize templates with
separate header and implementation files.

The cfront auto instantiation system won't bother attempting template
instantiation if it cannot find its type map, which is the file
ptrepository/defmap by default.  If one builds a library archive
containing unresolved template references in directory "A", then one
attempts to link against that archive in directory "B", template
instantiation will fail unless directory "B" happens to contain a type
map that allows cfront to locate all the types necessary to perform
the instantiation.  If the user in directory "B" has the necessary
write permissions for the repository in directory "A", s/he can use
the -ptr option to the compiler to specify that repository instead of
the default, and the link should then work.  If repository "A" is not
writable, the user can specify a writable directory as the first
repository on the command line, followed by another -ptr specifying
"A" as a read-only repository:

	CC ... -ptr my_ptrep -ptr A/ptrepository ...

All of this is well documented by the cfront release notes.

We have found it useful to create archive libraries that utilize
templates in three steps:

  1) create the archive library
  2) compile a dummy main program and link it against the archive
  3) redo the archive to include all of its original object files plus
     the object files created by the template instantiation system

This approach prevents archive library clients from having to perform
template instantiation for that archive.  A similar approach is
mentioned in the cfront 3.0 release notes, I think.  Makes sense and
saves a lot of needless instantiation time.

-steve

Newsgroups: comp.lang.c++
From: clerc@gla.ecoledoc.ibp.fr
Subject: operators
Keywords:  operators,inheritance
Reply-To: clerc@gla.ecoledoc.ibp.fr
Organization: Universite Paris VI/Paris VII
Date: Thu, 21 Jan 1993 16:56:21 GMT


Id like to express in C++ the fact that operators < <= >= can
be defined using operators > and = (eg: a < b  is b > a)
I would use a class MathObj (that would implement < <= >= using > and =)
and derive my classes from it, redifining only the basic operators > and =


How can I WRITE that in C++ ? (no template solution please)


thanx in advance

			clerc@gla.ecoledoc.ibp.fr




Newsgroups: comp.lang.c++
From: kanze@us-es.sel.de (James Kanze)
Subject: Re: Help w/ default arguments and more
Organization: SEL
Date: 28 Jan 93 17:12:14

In article <1jq475INNp69@tamsun.tamu.edu> ski8032@tamsun.tamu.edu
(Suman Kumar Inala) writes:

|> Also, I know I'm missing
|> something simple here, but the following doesn't work:

|> #define SWAP_INT(a, b) { a ^= b; b ^= a; a ^= b; }
|> inline void swap(int a, int b) {  a ^= b; b ^= a; a ^= b; }

|> The SWAP_INT macro works, but not my inline function.  Why?

The inline macro would work better if you declared the parameters as
references, ie:

	inline void swap( int& a , int& b ) ...

But in fact, neither the inline nor the macro work if you're swaping a
value with itself, ei:
	SWAP_INT( x , x )

Of course, no one would write this intentionally, but it will
occasionally pop up in algorithms to inverse arrays, sorting, etc.
(The programmer may decide that doing one swap too many in some
special cases is less expensive than adding an extra test in a tight
loop.)

This is difficult to avoid with the macro, but try the following
inline function:

	inline void
	swap( int& a , int& b )
	{
		int		tmp = a ;
		a = b ;
		b = tmp ;
	}

This should work in all cases, and in addition, will typically be
faster (at run-time) than the posted algorithm.  (Any compiler worth
its salt will get tmp into a register.)
--
James Kanze                             email: kanze@us-es.sel.de
GABI Software, Sarl., 8 rue du Faisan, F-67000 Strasbourg, France
Conseils en informatique industrielle --
                   -- Beratung in industrieller Datenverarbeitung
From: jimi@vnet.ibm.com (Jim Meyers)
Date: Sun, 24 Jan 93 13:17:39 EST
Newsgroups: comp.lang.c++
Subject: Compiler Conformance Testing

Does anyone know where I can find a language conformance suite for comparing
compilers? Thanks...

--------------------------------------------------------------------------
Jim Meyers
IBM Networking Systems
Research Triangle Park, NC
jimi@vnet.ibm.com
--------------------------------------------------------------------------
Newsgroups: comp.lang.c++
From: nh@cbnewsg.cb.att.com (nicholas.hounsome)
Subject: Re: Dynamic Linking and Sun Sparcs, do they mix?
Organization: AT&T
Date: Mon, 25 Jan 1993 08:40:30 GMT

From article <1993Jan23.043030.5358@aee.aee.com>, by gene@aee.aee.com (Gene Kochanowsky):
> Greetings,
> 
> 	I have a multi-platform project I am working on that requires the
> use of DDLs. I know there are many fine products on the PC that support such
> things. Does anyone know if there are any developement products that support
> DDLs on the Sun, and what version of the SunOS is needed. User preferences 
> are welcome.
> 
> 	
> Thanks
> 
> Gene Kochanowsky
> 
> gene@aee.aee.com
> -- 
> Gene Kochanowsky                           | "And remember ....
> Associated Electronic Engineers, Inc.      |       The better you look ... 
> (904)893-6741 Voice, (904)893-2758 Fax     |       the more you will see."
> gene@aee.com                               |               Miss Lidia

I can't think of anyting that would actualy require dynamic libraries but
assuming that you have a real need you might like to know that they are
the norm on most UNIX systems and have been for long before they became
trendy on PCs.

Any linker that you buy for suns will almost certainly support DLLs
certainly Sun's does - it is the default to link dynamicaly.

Newsgroups: comp.lang.c++
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: C++ maintenance
Organization: Computer Science, University of Melbourne, Australia
Distribution: na
Date: Thu, 28 Jan 1993 02:49:43 GMT

erc@netcom.com (Eric Smith) writes:

>In article <harvey.728009429@regina> harvey@opl.com (Harvey Reed) writes:
>>For example, our conventions require:
>>
>>m<name>       (m)ember data of a class
>>s<name>       (s)tatic data of a class
>>a<name>       (a)ctual parameter to a method
>
>Two suggestions:
>
>1.  To make member names obvious in a member function, prefix each with
>    "this->".  E.g., instead of invoking a member function as func()
>    invoke it as this->func()  (Because prefixing with 'm' or whatever
>    is a nonstandard convention which has to be learned by everyone
>    who looks at your code, but this->func() has standard C++ meaning
>    and is therefore "obvious" to everyone.)

A good suggestion. You can also prefix static data of a class with
"classname::", instead of using s<name>, and global variables
can be prefixed with "::".

-- 
Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
This .signature virus is a self-referential statement that is true - but 
you will only be able to consistently believe it if you copy it to your own
.signature file!
Newsgroups: comp.lang.c++,comp.object
From: tims@bcarh680.bnr.ca (Tim Spurway)
Subject: Re: Strong typing (was: Re: Pros and cons of C++)
Organization: Bell-Northern Research, Ottawa, Canada
Date: Wed, 27 Jan 1993 21:01:58 GMT

In article <1993Jan27.082721.3841@nwnexus.WA.COM> markmc@halcyon.com (Mark McWiggins) writes:
>samantha@shell.portal.com (Samantha Atkins) writes:
>
>>Am I going askew here or is it as it seems to me that so called strong typing
>>creates an untenable mess if you seriously attempt its use now and for the
>>future?
>
>Recompilation is an "untenable mess"? True, with CPUs even fast as they
>are now and tools relatively dumb, you can do unnecessary recompilation.
>
>But give me this any day over my customer calling from Buenos Aires
>saying "What's this 'method not found' mean?" as in Smalltalk.
>

But give me this any day over my customer calling from England saying
"What's this 'Segmentation fault: core dumped' mean?" as in C++.  :)


Tim Spurway
tims@bnr.ca
From: davidm@consilium.com (David S. Masterson)
Newsgroups: comp.lang.c++
Subject: Re: buffering iostreams
Date: 26 Jan 93 18:50:53 GMT
Distribution: comp
Organization: Consilium Inc., Mountain View, California
In-reply-to: quairoli@cs.widener.edu's message of 26 Jan 93 03:55:50 GMT
X-Posting-Software: GNUS 3.13  [ NNTP-based News Reader for GNU Emacs ]

>>>>> On 26 Jan 93 03:55:50 GMT, quairoli@cs.widener.edu (Patrick J. Quairoli)
>>>>> said:

> i'm trying to take a long (i.e. 72) and cast it as a char so
> that i get a value of 'H'.  this can be easily done by:

> long foo = 72;
> cout << (char)foo;

> BUT!  i also want the output to be buffered as an long (4 bytes).

[...deleted...]

What you are discussing is not referred to as "buffering".  Buffering is what
occurs when characters that you write to a stream are not immediately written
to the output location, but rather are held in internal memory until a
sufficient number have been "buffered" to be efficiently written out.

What you are looking for is output format control -- the process of making
your output look the way you want it to.  Doing this depends on exactly what
you're doing, but the easiest is:

cout << (char) foo << "   ";

All of the special format control mechanisms (like setw) that I see in
iostreams are used for controlling the appearance of numeric values (of which
foo casted to char is not).  For character string output, you have to do it by
hand (but you could hide that in a manipulator).

--
====================================================================
David Masterson					Consilium, Inc.
(415) 691-6311					640 Clyde Ct.
davidm@consilium.com				Mtn. View, CA  94043
====================================================================
	"Boldy going where no one has gone before."
Newsgroups: comp.lang.c++
From: brad@bradley.bradley.edu (Bradley E. Smith)
Subject: BC TButtons on TWindow/TDialog
Organization: Bradley University
Date: Mon, 25 Jan 93 21:38:03 GMT

being very new to tvision, I am looking for just a couple of things.

1-what is a good book for tvision, the supplied book doesn't seem to
  tell me what I want to know...maybe I am reading it wrong....
  I don't want a book with the same dumb examples as the supplied
  docs.
2-answers to the following "Why doesn a TButton have different
  colors on a TDialog than a TWindow"?

thanks, brad
-- 
Bradley Smith			 brad@bradley.edu ---  309-677-2337
Network & Technical Services @ Bradley University, Peoria, IL

"It's amazing how much scrap metal you get from 4 cans of beer"
From: robert@alkymi.unit.no (Robert Schmidt)
Newsgroups: comp.lang.c++
Subject: Publication database in C++
Date: 21 Jan 93 18:06:39 GMT
Organization: Norwegian Institute of Technology


I wondered if anyone has a simple publication database realized in C++,
or if you have good ideas and tips on how to implement it.

The database should be simple in that:

- the entire base is read in from a text file at program startup and kept 
  in memory
- the entire (modified?) base is written back to a text file at program
  exit.
This leads the mind to << and >> stream operators of course.

- no field definition is possible at run-time, i.e. no customizing is
  available in that area.
The class definitions are thus fixed at run time.

More challenging tasks follows:

- the records are variant, in that there are several fixed categories of
  publications, i.e. different fields should be enabled/disabled for each
  such category.
- fields that are not needed for a given record should not consume space
  in memory or in the disk file.

What the individual fields contain are not important, but there will be
need for strings, numbers, dates, "check boxes"/"y or n", i.e. different
sized/dynamically allocated fields.

Please reply with e-mail, as I seldom scan this  group.   If there is enough
interest (if any :) I might summarize.

Thanks!


robert@solan.unit.no
From: news@fedfil.UUCP (news)
Newsgroups: comp.lang.c++
Subject: C++, Borland, and Island-Hopping
Date: 22 Jan 93 03:54:05 GMT
Organization: HTE

I sincerely hope somebody from Borland is reading this.  I like Borland,
I've been using their products for a number of years, and have written
all of my most ambitious projects recently in BC++, other than for one
or two things which simply had to address large spaces for which I
used the DeLorie version of GCC.

Until recently, I have not bothered to even look at MicroSoft compiler products.
This may shortly change, however.  I do not believe that even Borland is 
sharp enough to continually play a game by the other side's set of rules and
keep coming out on top, particularly if the other side has the financial
resources and acumen which Microsoft does.

Tojo once said that America won WW-II by a combination of things, all of which
amounted to refusal to play the game by the other side's rules;  one of these
was "island-hopping", the notion of taking only those islands which we needed
as stepping stones to some point from which we could launch massive raids on
Japan itself.  Other islands were sealed off by sea and by air to serve only
as de-facto prisons for their garrisons.

Had we tried to take all of those islands, as the Japanese clearly expected
us to, this article would appear in Kanji characters.

Ceding operating systems to MicroSoft is like trying to take all the islands;
basically, this idea of OS neutrality which Borland and a couple of other
compiler venders profess is untenable. 

MicroSoft will soon announce a visual programming version of C++;  I intend to
take a hard look at this and may well end up using it at least for MS Windows
projects.  I can't believe that the owner of the MS-Windows game is going to
forever come up last in programming products for that environment.

Meanwhile, if what I'm reading about NT is correct, MS has left just a huge
opening for somebody to come out with some viable alternative to NT over
the next year, along with programming tools.  

It would be tremendously gratifying to have Borland come out and say, more
or less, that if all you can do is MS-Windows, we'll sell you compilers for
MS-Windows, but HERE's what we feel serious computer users ought to be
using and where our serious efforts will go.


-- 
Ted Holden
HTE