HDTenEightyP/NetNews huggingface dataset:
From: ark@alice.att.com (Andrew Koenig)
Newsgroups: comp.lang.c++
Subject: Re: template disappointments ... (suggestions?)
Date: 29 Dec 92 22:18:08 GMT
Reply-To: ark@alice.UUCP ()
Distribution: comp
Organization: AT&T Bell Laboratories, Murray Hill NJ

In article <DSCHIEB.92Dec29133556@muse.cv.nrao.edu> dschieb@muse.cv.nrao.edu (Darrell Schiebel) writes:

> 	(2) but worse than this minor item, it seems as though it is 
> 	    impossible to compose templates from templates:
> 		template<class t> class vector {};
> 		template<class t> class list {};

> 		list<vector<int>> list_vec_int;

Huh?? This works fine -- just remember to put a space between the
two > characters so the >> won't be taken for a shift-right symbol.
-- 
				--Andrew Koenig
				  ark@europa.att.com
Newsgroups: comp.lang.c++
From: pauljo@microsoft.com (Paul Johns)
Subject: Re: Can't I initialize a dynamically allocated object in its constructor?
Date: 23 Dec 92 20:27:51 GMT
Organization: Microsoft Corp.:  Redmond, Washington, USA

I forgot to change the distribution to world in my last post, so it
never got to the person who was asking.  Mea culpa.

I'm enclosing it verbatim below.  Mea culpa for the repeat.

I like the points the others have made, too!

// Paul Johns

In article <1992Dec22.234420.6610@microsoft.com> pauljo@microsoft.com wrote:
> You've made common beginning mistake #1:  not defining
> your own copy constructor when one is needed.
> 
> Your code WILL NOT WORK correctly until you provide a proper
> copy constructor.  The fact that it seems to work in one case 
> is not the whole story:  it is actually failing in subtle 
> ways you're not looking at.  And the initialization you ask
> about is not the issue here.
> 
> What's going on is that since you didn't provide a copy
> constructor, the compiler provides one for you which simply
> copies the members of your class one member at a time.
> 
> But the data in the vector doesn't get copied--only the pointer.  
> And you end up deleting data twice since two different objects 
> point to it.
> 
> This is really bad--it tends to mess up the heap something awful.
> 
> There is at least one C++ book whose author tells nothing
> of copy constructors.  I hope you didn't use that one!!!
> 
> Good texts (Lippman, Stroustrup, various Microsoft Press books,
> etc.) do a good job of explaining copy constructors and why 
> they're needed.  Check out the dynamic string classes, which 
> are very similar to your vector class.
> 
> If your class needs an assignment operator, it will almost
> certainly need a copy constructor and destructor as well.
> 
> Two other points I noticed in your code:
> 
> 1.  You assignment operator doesn't check for doing "a = a;"  Also,
> 	it DOES make sense to assign vectors of different sizes,
> 	you may want to allow that.  Check how a good dynamic
> 	string class works for ideas.
> 
> 2.  operator + is usually implemented as a file-scope (global)
> 	function so that both operands can be converted, not
> 	just the RHS operand.  In your particular case, you
> 	don't have any useful (meaning you'd want to write
> 	something like "vecx = 5 + vecy;") conversions, so 
> 	this isn't an issue.  You may want to rethink the
> 	int constructor since it provides an implicit conversion
> 	from int to vector, meaning that an int or any expression
> 	that can be converted with a standard conversion to an
> 	int can be used any place a vector can.  (So "vec2 + 5"
> 	**IS** legal for your class, although meaningless.)
> 
> Good luck!
> 
> // Paul Johns
From: ren@function.mps.ohio-state.edu (Liming Ren)
Newsgroups: comp.lang.c++
Subject: Automatic conversion! Can we do this?
Date: 22 Dec 1992 15:11:52 -0500
Organization: Department of Mathematics, The Ohio State University
Distribution: world
NNTP-Posting-Host: function.mps.ohio-state.edu

I wrote a string class and overloaded  operator + to achive the function
of strcat(). It is my understanding that the compiler will do the conversion
from char * to string using the function I supplied. What is strange is I can
do:

string a, b("Merry");
a=b+" Chrismas";
a="C" + b;

But I can't do:   a="Merry" + " Chrismas";
The compiler complains that "pointer +pointer" and the conversion does not 
happen. I tried to overload + with (char*, char*). The compiler did not 
allow me. HERE is the class:

class string{
  char *str;
  int size;
 public:
  string()  {str=new char[10]; size=9;}
  string(const char *p){ str=strdup(p); size=strlen(p);}
  string(const string& s){str=strdup(s.str); size=s.size;}
  ~string(){delete [] str;}
  string& operator=(const string&s){/*body*/    }
  friend string operator+(const string&,const string&){/*body*/}
};

main()
{
  string a;
  a="Merry" +" Chrismas";
}

It seems to me the compiler has no clue what is going on if I supply two
pointers. It needs at least one operand to be string to invoke the
overloaded + on string class. Is there a way to overcome this?


Merry Christmas!
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c++
Subject: Re: Make a deep copy!
Date: 22 Dec 92 22:41:34 GMT
Organization: negligable

In article <kwong.724744711@morgan> kwong@morgan.ucs.mun.ca (KAI S. WONG   ^.^) writes:
:
:
:In article <1992Dec11.232954.7071@borland.com>, pete@borland.com (Pete Becker) writes:
:>> In article <1992Dec11.170849.18525@rs6000.bham.ac.uk> pickerig@eee.bham.ac.uk (Guy Pickering) writes:
:>> >In general, can I create an instance of a class in a member function and
:>> >return the object? Doesn't the complex object go out of scope?
:>> 
:>> 	Yes, it does.  But that's not the end of the inquiry.
:>> 
:>> 	int add( int a, int b )
:>> 	{
:>> 	return a+b;
:>> 	}
:>> 
:>> 	Here, too, the temporary goes out of scope, but the compiler knows how
:>> to deal with that.  Same thing for an object of a user-defined type.
:>> 
:
:How about if the structure is a bit more complex, especially one with
:dynamically allocated memory.  I tried the following (I appologize if it's
:syntactically incorrect, I no longer have the version which I actually tried.
:This one is just from memory):
:
	[ ... example deleted ... ]
:
:the "+" operation works and sum contains the proper matrix, that is until
:"+" finishes and goes out of scope.  The "return" statement makes a temporary
:copy of sum (ie. the values of its nrows, ncols, and the pointer entry), and
:then proceed to destroy sum automatically.  So, now the entry pointer of this
:temporary is no longer pointing to a valid block of memory!!   
:
:Is this really what happened?  I am new to C++, I am not sure my interpretation
:is correct.  But all I can tell is that this simple addition and assignment 
:sequence DOESN'T work, and I don't know how to get around it.  HELP!!

I believe that these are the situations that indicate that you 
need to have a copy constructor and the operator=() defined for 
your class.

I'm sure someone will correct me if I'm wrong.		:)


		-Richard Hartman
		hartman@uLogic.COM

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"Ideas are not responsible for the people who believe them."

Newsgroups: comp.lang.c++
From: Ian_Upright@mindlink.bc.ca (Ian Upright)
Subject: C++ Source code / files, etc..
Organization: MIND LINK! - British Columbia, Canada
Date: Thu, 31 Dec 1992 01:22:43 GMT

Can anybody provide me of the location and ftp sites of the FAQ for this
group, and I was wondering if there were any ftp sites that had C/C++ code..

Is there any file lists of the available freeware c++ code??   Thanks..

--
/-----------------------------------------------------------------------------
  Origin:  Astaria Digital Enterprises             Ian_Upright@mindlink.bc.ca
  BBS: (604) 852-1866, or FidoNet  :-)  1:153/513                  CANADA eh?
\-----------------------------------------------------------------------------
/
Newsgroups: comp.lang.c++
From: max@ise.fhg.de (Max Kubierschky)
Subject: Re: Newing a pointer to a pointer
Organization: FhG-ISE - Institute for Solar Energy Systems
Date: Wed, 30 Dec 92 14:42:51 GMT

jlnance@eos.ncsu.edu (JAMES LEWIS NANCE) writes:


>I am attempting to learn C++.  I have declared a class called list and class
>called generic.  In generic, lspace is declared as:

>list **lspace.

>Both g++ and cfront tell me that the line containing new in the following 
>constructor has a syntax error.

>generic::generic() {
>this->lrow   = 100;
>this->lcol   = 100;
>this->lsize  = 0;
>this->lspace = new *list[lcol];
>this->addrow();
>printf("Constructing element\n");
>}

>Can someone tell me what I am doing wrong?

If you want to create an array of pointers to lists, try:
`this->lspace = new list*[lcol];'
Note that this statement won't create any list
btw: Why do you explicitly use this?
`lspace = new list*[lcol];' 
will do the same (while being in class scope).
--
Max Kubierschky                    "Don't Bb, but try to C#"
Haendelstr. 20/218
D 7800 Freiburg, West Germany
phone: +49 (761) 53664 or +49 (761) 4014-109
email: max@ise.fhg.de
Newsgroups: comp.lang.c++
From: bruceb@roadrunner.denver.sgi.com (Bruce Bailey)
Subject: Re: class forward ref. in C++
Organization: Silicon Graphics, Inc.
Date: Thu, 31 Dec 1992 21:14:46 GMT

In article <1992Dec31.201340.13142@twisto.eng.hou.compaq.com>,
giangd@gocart.eng.hou.compaq.com (Giang Dao) writes:
|> Dear C++ gurus,
|> I have the following question :
|> 
|> class A
|>   {
|>    ...
|>    B * bptr;
|>    ...
|>   }
|> 
|> class B
|>   {
|>    ...
|>    A * aptr;
|>    ...
|>   }
|> 

Can't you just do a forward declaration of B?

e.g.,

class B;

class A
  {
   ...
   B * bptr;
   ...
  }

class B
  {
   ...
   A * aptr;
   ...
  }

Bruce Bailey (bruceb@denver.sgi.com)
From: moudgill@cs.cornell.edu ( Mayan Moudgill)
Newsgroups: comp.lang.c++
Subject: Help!!! need a work-around for a bug in cfront 3.0.1
Keywords: cfront 3.0.1, bug, example, workaround, help
Date: 27 Dec 92 11:31:36 GMT
Article-I.D.: cs.1992Dec27.113136.3320
Organization: Cornell Univ. CS Dept, Ithaca NY 14853

I found a bug in cfront 3.0.1. The included program exhibits this
bug. Static functions A<T>::foo() and A<T>::bar() both
call static function B<sizeof(T)>::gah(). gah() prints
out the value of sz i.e. sizeof(T). They turn out to be
different.

Has anybody encountered this bug before? Could anybody suggest
a workaround?

please,
Please,
PLEASE,
_PLEASE_,
*PLEASE*

:(
Mayan
(moudgill@cs.cornell.edu)

------------------------- CUT HERE ----------------------------
#include <iostream.h>

template<class T>
class A {
public:
   static int foo();
   static int bar();
};

template<unsigned sz>
class B {
public:
   static
   int gah()
      {
         cerr << sz << endl;
	 return 0;
      }
};


template<class T>
int A<T>::foo()
{
   return B<sizeof(T)>::gah();
}

template<class T>
int A<T>::bar()
{
   return B<sizeof(T)>::gah();
}

main()
{
   A<double>::foo();
   A<double>::bar();
}
Newsgroups: comp.lang.c++
From: saud@seas.gwu.edu (Temporary account (slc 11/19/92))
Subject: source code of Stanley Lippman Book
Organization: George Washington University
Distribution: usa
Date: Wed, 23 Dec 1992 16:02:38 GMT


It has being asked and answered the question of where to get the 
source code of Stanley Lippman's Book.

Could some one please reposted the ftp address.

Thanks

wanes

Newsgroups: comp.lang.c++
From: dwr@cci632.cci.com (Donald W. Rouse II)
Subject: Re: File protection on iostreams
Organization: [Computer Consoles, Inc., Rochester, NY
Date: Tue, 22 Dec 1992 18:05:56 GMT

In article <1992Dec15.212053.4733@pixel.kodak.com> morss@ssd.kodak.com (Charlie Morss) writes:
>
>According to Strus. the header files for fstream.h in the
>third arguement for the open call specifies the
>file protection mode, as in chmod, for the file
>you are creating. When I use a protection mode of
>664, when the file is created it has a protection
>mode of 644, which is the default. Is there a 
>reason that the file protection mode is not
>done correctly.

Yes.  Look at umask(2) and open(2) in your reference manual
to see how they interact.
Use the umask(1) command to examine or change your umask,
or, in the program, you can do something like:

	int oldumask = umask (0);
	// do your open
	(void)umask (oldumask);

[...]
>P.P.S. If I do "normal" opens (old fashion C) 
>	   everything works fine!!

Are you sure about this?  It should suffer from the same problem.
From: cshaver@informix.com (Craig Shaver)
Newsgroups: comp.lang.c++
Subject: Re: Need help implementic data structures of generic objects
Date: 23 Dec 92 21:29:22 GMT
Organization: Informix Software, Inc.

In article <1992Dec17.104357.3422@unix.brighton.ac.uk> je@unix.brighton.ac.uk (John English) writes:
>cshaver@informix.com (Craig Shaver) writes:
>: It is obvious to me that you have a virtual function in the base class for 
>: all functions that you need to use when dealing with 'Objects'.
>: 
>: If you use a function on a class that is only restricted to a certain
>: sub-tree of your inheritance structure, then you know what you are using,
>: ergo, you should have used that type instead of 'Object'.
>
>Yes, but then you end up migrating a lot of the functionality of your
>hierarchy into class Object, in much the same way as widely-used data
>structures end up being global in C.
>

There should not be much, if any, real code in the base class virtual function.
You may just want to have an error print out or exception handler to show that
this function is to be implemented by a subclass.  If you can come up with 
generic code, then put it in the base class and share it.  The base 'Object'
at the very top of the tree should have very little functionality.  By base
I mean the top of any tree type hierarchy.  

You are right to say that sometimes code sharing in the base class is like using 
globals.  It is difficult to achieve and should be well thought out.  If it is 
poorly formed code (most likely because of the way the classes have been designed) 
then it will not be used in practice, and sub-classes will reimplement the 
functionality to achieve their goals.


-- 
Craig Shaver  (cshaver@informix.com for now) (415)390-0654 (415)926-6407
Productivity Group POB 60458 Sunnyvale, CA  94088
Newsgroups: comp.lang.c++
From: max@ise.fhg.de (Max Kubierschky)
Subject: Re: How to attain Eternity (getting by the universal destructor :)
Organization: FhG-ISE - Institute for Solar Energy Systems
Date: Mon, 28 Dec 92 15:31:52 GMT

mfrutig@tnd81 (Mark Frutig) writes:

>In article <1992Dec05.234122.10911@crash> classics@crash.cts.com (Baruch  
>Schwartz) writes:
>> 			The Original Kriya Science
>> 		(How to Attain eternal Realization of the ultimate Self)
>> 
>> 				The Message
>> 				-----------
>> 
>> 	Can thirst be quenched by merely shouting the word "water"? 
>> Certainly not! Shouting only worsens the situation. The uttering of  
>words 
>> does not produce the desired results as some devotees advocate and 
>> propagate.
>> 
>> etc, etc, etc
>This is a very interesting progarmming problem.  My feeling is that we can  
>template Brahma and subclass such issues as "The Message".  Anyone
>have any ideas how other major religions might be implimented in code.
I see a Problem in implimenting monotheistic religions:

class God
{
  private:
	God();
  public:
	static God Lord;
  //...
};

won't work with all compilers. How to make shure, that there can be only 
one instance of God? This should be checked at compile time. For I think
a message like "God died due to blasphemy error (soul dumped)" at
run time wouldn't be the solution.
btw: I saw a quotation of Cato the Elder's "ceterum conseo
Carthaginem delendam esse" in someones .signature. As we know, he had the 
habit of saying that when finishing a speech to the Senat.
Is there any evidence, that he also called for a new Carthago at the
beginning of his speeches? If not, could this have been the true
reason for the final breakdown of the roman empire?
--
--
Max Kubierschky           "Don't Bb, but try to C#"
Haendelstr. 20/218
D 7800 Freiburg, West Germany
phone: +49 (761) 53664 or +49 (761) 4014-109
email: max@ise.fhg.de
Newsgroups: comp.lang.c++
From: tpenttin@majakka.uku.fi (Tommi Penttinen)
Subject: Serious problem with BC++ 3.0
Date: 28 Dec 92 22:23:56 GMT
Organization: University of Kuopio, Finland

When I try to compile one of my c++ files, BC (IDE version) halts the
compilation with an error message at some point and I have no idea what's
causing it. The error looks something like this:
	EXCEPTION 13:general protection fault at 0A7F:03C0 error code 1768
	...
According to the above message segments ds, cs and ss point to BC.EXE (or
some part of it..)
Has anyone seen this error and/or does anyone know what's wrong here?
I have Windows 3.1 and I am using its himem.sys and emm386.exe; could that
be causing the problem?
Please, help me!

Any replies appreciated.

++Tommi
-- 
      +---------------------------------------------+-----------------------+
 O o  +   My social-security#: 35^3fd1"q@ (coded;)  +  Tommi Penttinen      +
  _   +   ++(Tomm:)  /* Live long and prosper */    +  tpenttin@cs.uku.fi   +
      +---------------------------------------------+-----------------------+
Newsgroups: comp.lang.c++
From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
Subject: Re: Borland C++ compiler products ?
Organization: Texas Instruments Inc
Date: Thu, 31 Dec 1992 21:56:25 GMT

In <8905@lhdsy1.lahabra.chevron.com> hwrvo@kato.lahabra.chevron.com (W.R. Volz) writes:

>Could someone explain the difference between:

>Turbo C++ for dos or windows

A lower end product for either DOS or Windows (depending on which one
you buy), it contains some optimization, some IDE debugging
capability, and an inline assembler.  If you don't know C++ and want
something to learn with and to write small programs with for either
DOS or Windows, these are probably the way to go.

>Borland C++

The full-blown professional product.  Includes compilers for both DOS
and Windows, both IDE and command line, full optimization, IDE
debugger, separate debugger, profiler, separate assembler and linker,
various tools for building things, etc.  Can also be ordered with
Application Frameworks, a group of classes for doing Windows and DOS
programming that provide a lot of common functionality (UI type stuff,
etc.).  This is a LARGE package -- takes up like 40+MB on disk if you
load the whole thing, requires 2 MB of memory (i.e., you must have a
286 or better with EMS memory to even load it up), etc.

>Both are from Borland. A fact sheet I got from Borland at OOPSLA said
>that Turbo C++ is based on cfront 3.0 but the back of a box at a local
>store said cfront 2.1. If they are the same product, why the difference
>in price of about $200. They have to be giving something for the extra
>bucks.

Hope this explains what you're getting for that extra money.

-- 
"Insisting on perfect safety is for people who don't have the balls to live
 in the real world."   -- Mary Shafer, NASA Ames Dryden
------------------------------------------------------------------------------
Fred.McCall@dseg.ti.com - I don't speak for others and they don't speak for me.
Newsgroups: comp.lang.functional
From: nirad@newdelphi.ceu.uq.oz.au (Nirad Sharma)
Subject: Where can I find pc-/mac- versions of miranda ?
Organization: Continuing Education Unit, The University of Queensland
Date: Tue, 22 Dec 1992 08:14:22 GMT

Any suggestions ?
--
Nirad Sharma  (nirad@ceu.uq.oz.au)			Phone : (+61 7) 365 7575
Continuing Education Unit				Fax :	(+61 7) 365 7099
The University of Queensland.  QLD  4072.  AUSTRALIA
From: goodrich@lynx.larc.nasa.gov (Mike Goodrich)
Newsgroups: comp.lang.functional
Subject: Completely functional program in C
Date: 23 Dec 1992 21:07:23 GMT
Organization: NASA Langley Research Center, Hampton, VA  USA
Distribution: world
NNTP-Posting-Host: lynx.larc.nasa.gov


Greetings,
	The following is an example of a functional program in C I wrote after
reading MaClannan's book on FP. I would like to invite comments from the FP
community. I was pleased to find that the Sun C optimizer knows about tail recursion optimization so that this program runs as fast as the conventional
C version that it is based on.





/*
 * Hexdmp.c
 * 
 * Author: Mike Goodrich (804) 864-1790   goodrich@128.155.25.38  (goodrich@lynx.larc.nasa.gov)
 * 
 * Purpose to dump a given file to STDOUT in hex and ascii
 *
 * NOTE: This version was rewritten to adhere to the 'functional program' paradigm
 *
 * Usage:	hexdmp <filename>
 * 
 * Note:	If compiling under Microsoft C must use -J to overide signed char
 * default.
 */



#include	<stdio.h>
#define REC_SIZE	16
static unsigned char HexTab[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f'};

void            PutHexLine(), PutTextLine(), DoLine(), DumpFile();


main(argc, argv)
	int             argc;
	char          **argv;
{
	unsigned char   buff[REC_SIZE];

	if (argc < 2) {
		printf("\nUsage: hexdmp <filename>\n");
		exit(0);
	}
	DumpFile(fopen(argv[1], "rb"), buff);
}

void
PutTextLine(NumRead, buff)
	short           NumRead;
	unsigned char  *buff;
{
	switch (NumRead) {
	case 0:
		return;
	default:
		if (*buff < ' ' || *buff > '~') {	/* printable ? */
			printf(".");
		} else {
			printf("%c", *buff);
		}
		PutTextLine(NumRead - 1, buff + 1);
	}
}

void
PutHexLine(NumRead, buff)
	short           NumRead;
	unsigned char  *buff;
{
	switch (NumRead) {
	case 0:
		printf("\t");
		return;
	default:
		printf("%02x ", *buff);
		PutHexLine(NumRead - 1, buff + 1);
	}
}

void
DoLine(NumRead, buff, count, fp)
	short           NumRead, count;
	unsigned char  *buff;
	FILE           *fp;
{
	switch (NumRead) {
	case 0:
		return;
	default:
		printf("\n<%d>\t", count * REC_SIZE);
		PutHexLine(NumRead, buff);
		PutTextLine(NumRead, buff);
		DoLine(fread(buff, 1, REC_SIZE, fp), buff, count + 1, fp);
	}
}

void 
DumpFile(fp, buff)
	FILE *fp;
	unsigned char  *buff;
{
	if (fp == NULL) {
		printf("Error: cannot open input file\n");
		exit(-1);
	}
	DoLine(fread(buff, 1, REC_SIZE, fp), buff, 0, fp);
}



Newsgroups: comp.lang.functional