HDTenEightyP/NetNews huggingface dataset:
From: chou@umvlsi.ecs.umass.edu ()
Subject: Learning C++
Originator: chou@umvlsi.ecs.umass.edu
Organization: University of Massachusetts, Amherst
Date: Fri, 8 Jan 1993 20:43:21 GMT

Hi,

I haven't followed this newsgroup before, therefore, I am afraid the
following question might be a FAQ. 

Can someone give me some recommendation about learning C++?
Basicly, I am looking for books with lots of examples and homework 
assignments. I know C and UNIX, but not C++, and have very little 
object-oriented experience. 

Please send your email to me.

Any help is appreciated!
Thanks,
-Yon
Newsgroups: comp.lang.c++
From: pauljo@microsoft.com (Paul Johns)
Subject: Re: Passing 2-d arrys to functions
Date: 11 Jan 93 23:45:45 GMT
Organization: Microsoft Corp., Redmond, Washington, USA
Distribution: usa

In article <RUNE.93Jan10125255@pandora.nta.no> rune@nta.no wrote:

> I'm including a little program that seems to work fine. Here I'm pas-
> sing only the pointer to  a two dimensional array.  Can I expect such
> programs to work, and if so, why?

Your program will work.  It is set up correctly.

But you are NOT passing the pointer to a two-dimensional array.

You are passing the pointer to an array of pointers.  Although
the syntax for accessing an element is the same (x[i][j]), the
underlying data structure is entirely different.

Note, for instance, that there's no reason that the row lengths
need to be the same.

When you pass a two-diminsional array, you really pass a pointer
to a one-dimensional array (i.e.  TYPE (*p)[ROW_SIZE]; )

Your example passes a pointer to a pointer.

Check the assembly language generated by the compiler to see the
difference.

// Paul
Newsgroups: comp.lang.c++
From: mat@mole-end.matawan.nj.us
Subject: Re: Newbie Wants Advice on C-Programming
Organization: :
Date: Mon, 4 Jan 1993 09:19:53 GMT

In article <4284@dozo.and.nl>, jos@and.nl (Jos Horsmeier) writes:
> In article <24538@alice.att.com> bs@alice.att.com (Bjarne Stroustrup) writes:

> |jimlynch@netcom.com (Jim Lynch @ Netcom Online Communications Services (408-241-9760 login: guest)) wrote
> |
> | > >For C++, it is _The_C++_Programming_Language 2nd ed. by Stroustrup
> | > No no no no no no no no no no no no. These books are _unreadible_ to
> | > a beginner. ...
 
[Bjarne:]
> |It is worth remembering that `beginner' means different things in different
> |contexts and what `unreadable' means depends critically on what kind of
> |beginner we are talking about.
 
> I think there's a bit more to leaning C++ than there is in learning C.
> ...  IMHO there are tree types of `beginners':
 
> - First time programmers;
> - Experienced programmers but still unaware of the OOD concepts;
> - Experienced programmers aware of OOD concepts, but they don't know
>   anything about the C++ language.
 
> I think that one has to be a beginner of the third kind to be able
> to learn the C++ language successfully.

I'll _still_ argue with this.  The Structured world has had the concept
of `informational clusters'; Ada has its packages; other languages and
approaches have had steps, larger or smaller, towards ADT programming.

C++ is _not_ an OOPL; it is a PL which supports ADT, OOP, and many other
approaches.  Moreover, it supports them in a unified way; with some
practice in the ADT world, it is natural to step into the OO world.

Certainly, some notion of ADT _or_ OO programming will help.  But these
don't require experience in languages that support them.  Kernighan and
Plauger write ``Choose a data representation that makes the program
simple,'' and ``Let the data structure the program,'' and then give
examples in PL/I and FORTRAN-66.  Page-Jones, in _The Practical Guide
to Structured Systems_, writes of Informational Clusters.  And even
Brooks, in _The Mythical Man-Month_, writes of surrounding data with
access functions that abstract the data into the permissible
operations on it.

Perhaps what is needed is being a skilled programmer and a skilled
program architect/designer.
-- 
 (This man's opinions are his own.)
 From mole-end				Mark Terribile

 mat@mole-end.matawan.nj.us, Somewhere in Matawan, NJ
From: mark@yvax.byu.edu
Newsgroups: comp.lang.c++
Subject: Borland C++ 3.1 w/ Application Frameworks
Date: 5 Jan 93 14:56:51 -0700
X-From: mark@yvax.byu.edu
X-Newsgroups: misc.forsale.computers.pc-clone
Followup-To: comp.lang.c++,misc.forsale.computers.pc-clone

X-Date: 5 Jan 93 14:56:04 -0700
X-Organization: Brigham Young University

	Brand new, unopened, unregistered

	Borland C++ 3.1 with Application Frameworks.

	Best reasonable offer takes it.

	Please respond to mark@yvax.byu.edu 

-Mark
Newsgroups: comp.lang.c++
From: cshaver@informix.com (Craig Shaver)
Newsgroups: comp.lang.c++,comp.object
Subject: Re: Pros and cons of C++
Date: 7 Jan 93 22:02:53 GMT
Organization: Informix Software, Inc.

In article <C0Hp1n.vp@gpu.utcs.utoronto.ca> yjohn@gpu.utcs.utoronto.ca (John Ross) writes:
>Hi Netters,
>
>I just read a paper by Markku Sakkinen titled "The Darker Side of C++
>Revisited," (Structured Programming [1992] 13: 155-177).
>
>He gives a very lengthy critique of C++'s characteristics--mostly
>negative, many due to the language's origins in C.  He concedes C++ may
>be ok for systems programming, or as an intermediate language, but he is
>afraid it will become _the_ o-o language.  He seems to think languages
>like Eiffel or Smalltalk would be preferable, though he does say no
>current o-o language is perfect.

Application programmers need an easy to use and hi level platform not
a complex language.  The platform might be implemented in c++ and may
generate c++ code, but the user should not have to know that.  The 
user/programmer has to concentrate on solving the application problems
not the language problems.  At this time there are few platforms that
even come close to being general purpose and non-proprietary.
Hence, Smalltalk, Eiffel, or NextStep deserve a look.

>
......
>
>Anyway, enough rambling--what are your thoughts?  Do you use C++; will
>you; what do you like, dislike about it; what is it's future; etc, etc?
>

I will use it reluctantly.  It is better than plain C only because of 
classes and inheritance; the rest of the 'enhancements' being of
dubious value (IMnsHO).

-- 
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: nikki@trmphrst.demon.co.uk (Nikki Locke)
Subject: Re: static "inheritance" question
Reply-To: nikki@trmphrst.demon.co.uk
Distribution: world
X-Mailer: cppnews $Revision: 1.30 $
Organization: Trumphurst Ltd.
Date: Wed, 6 Jan 1993 12:09:22 +0000

In article <1993Jan4.144320.5586@dayfac.cdc.com> pault@dayfac.cdc.com (Paul Thompson;DAYFAC-ITS;) writes:
> Consider class A which counts its 'live' instantiations.
>  
>             class A {
>                 static int nr;
>               public:
>                 A() {nr++;}
>                ~A() {nr--;}
>                 int getNrInstances () {return nr;}
>             };
>             ...
>             A::nr = 0;
>  
> A has useful functionality which I would like to use in other
> classes with MINIMAL change to the other classes. One way
> is to try:
>  
>     class B :public A { ....};
>     class C :public A { ....};
>      ...
>     B b1, b2, b3;
>     C c1, c2;
>     cout << B::getNrInstances();
>  
> But this doesnUt work because static variables aren't inherited
> (at least not in my compiler).

This DOES work, but perhaps not in the way you intended. It counts how 
many objects of type A are created. I.e. the total of all A's, B's and C's
together.

> Could anyone enlighten me as to how to acquire the functionality
> of a class like A that depends on a static variable with LEAST
> modification to the acquiring class ? Thanks.

I would suggest that A is turned into a template class. I compiled and 
tested the following under Borland C++ ...

#include <iostream.h>

template <class X> class Counted {
	static int nr;
public:
	Counted() {nr++;}
	Counted(const Counted &copy) { nr++; }		// You NEED this !
	~Counted() {nr--;}
	static int getNrInstances () {return nr;}	// Note static !
	};

class A : public Counted<A> {
	};
int Counted<A>::nr = 0;

class B : public Counted<B> {
	};
int Counted<B>::nr = 0;

class C : public Counted<C> {
	};
int Counted<C>::nr = 0;

main()
{
	A a1, a2, a3;
	B b1, b2;
	C c1;

	cout << " A:" << A::getNrInstances();
	cout << " B:" << B::getNrInstances();
	cout << " C:" << C::getNrInstances();
	return 0;
}

-- 
Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
Newsgroups: comp.lang.c++
From: af458@yfn.ysu.edu (Jon K. Salmon)
Subject: How to limit string output length w/ stream manips?
Organization: Youngstown State University/Youngstown Free-Net
Date: Fri, 8 Jan 1993 02:58:36 GMT


NetHeads,

I would like to limit the output length of a string sent to an
output stream.  For example, given a string...

  const char *Bob = "1234567890ABCDEF";

are there any manipulators or combination of manipulators which
would allow

  cout << [manip [manip [...]]] << Bob;

to output "12345"?  I have tried combinations of setw(), setfill(),
and setprecision() to no avail.  Anyone know what will?  Or am I
resigned to either a) limiting the string length itself, or
b) writing my own manipulator?

-- Jon
-- 
Newsgroups: comp.lang.c++
From: erc@netcom.com (Eric Smith)
Subject: Re: feedback wanted on appropriate OOPL
Organization: Netcom - Online Communication Services (408 241-9760 guest)
Date: Sun, 10 Jan 1993 22:09:17 GMT

In article <TMB.93Jan10170408@arolla.idiap.ch> tmb@idiap.ch writes:
>It is only true to say that _at compile time_, C++ will catch more
>programmer errors than Smalltalk.
>
>If you take into account both compile time and runtime, Smalltalk will
>catch more "programmer errors" than C++: not only will Smalltalk catch

But when is runtime?  When the program starts running, or when it
encounters unusual data several years after it's put into production?

The advantage of compile time error detection is that all the errors
that can be caught by the compiler are caught before the program is
released.
Newsgroups: comp.lang.c++
From: arthur@solomon.technet.sg (Arthur Sombrito)
Subject: About class template names
X-Newsreader: TIN [version 1.1 PL8]
Date: Thu, 7 Jan 1993 09:45:44 GMT

Hi,

According to the ARM, a class template name must be unique in a program
and may not be declared to refer to any other template, class, function,
object, value, or type in the same scope.

Does this mean that a name previously used as a class template name
can't be reused in another scope? For example:

   template <class T> class U {};
   enum U {};    // This should be an error. I am wondering why GNU
                 // and Borland accepted this.
   f() {
     union U {}; // So is this an error?
   }

Thanks for any replies.
From: cbusch@ub.d.umn.edu (Chris)
Newsgroups: comp.lang.c++
Subject: Overloading [] for 2d+ matrixes
Date: 4 Jan 1993 20:27:33 -0600
Organization: University of Minnesota, Duluth
NNTP-Posting-Host: ub.d.umn.edu

   I been programming in C++ for quite a while now, but something
occurred to me, how can you overload [] for 2d or 3d plus matrices?
Apparently the only allowable syntax is:
   myclass::operator [] (int);


--
-=-=-=-=-=-=-=-=-= Chris Busch     cbusch@ub.d.umn.edu =-=-=-=-=-=-=-=-=-=-
 C(o_o))        _                        "The use of COBOL cripples the
   (=)         (_ -|- -|- is the         mind; its teaching should, 
  --|--        language of choice.       therefore, be reguarded as a
   /^\      Protest the use of BASIC!    criminal offense." -E.W. Dijkista
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
From: cmlow@iti.gov.sg (Low Chee Meng (KSL))
Subject: Help: using GDB to debug G++-compiled programs
Organization: National Computer Board, Singapore
Date: Mon, 11 Jan 1993 12:22:50 GMT

Hi,

I'm currently using GDB to debug a C++ program (compiled with
-g flag with G++). One thing I couldn't figure out how to do is to
execute some method call inside GDB, eg:

gdb> print someObj.someMethod(someArgs....)
   or
gdb> set someVar = someObjPtr->someMetthod(....)

GDB would always return back something like "there's no component
named someMethod", even though someMethod is a valid method of
the class to which someObj belongs to.

Is there something I have to do make the above work? has anyone ever
had success getting GDB to execute any method call?

I'm current using GDB 4.6 and GCC 2.2.2 on Sun OS.

Thanks in advance for any help,

Chee Meng


-- 
---------------------------------------------------------------------
Chee-Meng Low (cmlow@iti.gov.sg) (fax: 65-777-3043)
Knowledge Systems Lab, Information Technology Institute, Singapore
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Newsgroups: comp.lang.c++
From: se_rossb@rcvie.co.at (Bernhard Rossboth)
Subject: Re: why `int X: :X()' ?
Reply-To: se_rossb@rcvie.co.at
Organization: Alcatel ELIN Research
Date: Mon, 11 Jan 1993 16:01:39 GMT

In article 5501@miramon.lulea.trab.se, jbn@lulea.trab.se (Johan Bengtsson) writes:
>Matt Wette (mwette@csi.jpl.nasa.gov) wrote:
>
>: Why are constructor and destructor functions usually declared to return
>: ints when the usage typically warrents a `void' declaration.
>
>The "default int" rule does not apply to constructors and destructors.
>You can't return an "int" from those functions.  You can't explicitly
>mark them as procedures (void) either.

"No return type (not even void) can be specified for a constructor."

Ellis & Stroustrup: The Annotated C++ Reference Manual page 265.
From: hlf@nic.cerf.net (Howard Ferguson)
Newsgroups: comp.lang.c++
Subject: Re: Restatement and clarification of "static inheritance" question
Date: 8 Jan 1993 18:10:37 GMT
Organization: CERFnet Dial n' CERF Customer Group
NNTP-Posting-Host: nic.cerf.net
Keywords: inheritance

>>WHAT I AM INTERESTED IN IS THE FUNCTIONALITY OF "COUNTING ONE'S
>>OWN INSTATIATIONS", NOT COUNTING THE TOTALITY OF ALL INSTATIATIONS OF
>>CLASS A. 
>
>	class A {
>		int & counter;
>	public:
>		A(int& c) : counter(c) {++counter;}
>		~A() { --counter; }
>	};
>
>	class B : public virtual A {
>		static int counter;
>	public:
>		B() : A(counter) { ... }
>	};
>
>	int B::counter=0;
>
>Without templates. Exercise: Prove it works! Prove you cannot
>get away without declaring and defining the counter in
>each class manually.
>
>There are a number of possible ways that might fix this using templates.
>You would have to do something like:
>
>	class B : public virtual A<B> { ...
>
>which seems dubious. Then the template class A<T> could create
>the int A<T>::counter automagically. Dont know if this
>works.
>

I still do not see a reason for inheritance when containment will do.
Can anybody clarify this???

	hlf
From: rons@hardy.u.washington.edu (Ronald Schoenberg)
Newsgroups: comp.lang.c++
Subject: Re: Overloading [] for 2d+ matrixes
Date: 6 Jan 93 02:25:12 GMT
Article-I.D.: shelley.1idfu8INNen2
Organization: University of Washington, Seattle
NNTP-Posting-Host: hardy.u.washington.edu

In article <HUGH.93Jan5194117@kahu.cosc.canterbury.ac.nz> hugh@kahu.cosc.canterbury.ac.nz (Hugh Emberson) writes:

[...elision....]

>
>2) The not so elegant solution.
>
>Don't use [], use () instead.
>
>	Y& X::operator () (whatever, whatever)
>
>and use
>
>	a(i,j);
>
>
>It should be a bit faster, but its not as pretty.  It has the same
>precedence as [] too.
>
>Hugh
>--
>Hugh Emberson -- CS Postgrad
>hugh@cosc.canterbury.ac.nz

Ugliness here is in the eye of beholder.  Personally, I think addressing
a two-dimensional array as a[i][j] is ugly.  And more work.  Maybe it's
because I touch-type, but I find a(i,j) a lot easier to type than a[i][j].

Trying to overload operator [] for matrix classes generally seems to 
create more problems than it solves.  I've some experience with matrix
classes and that experience suggests that it is better to stick to 
-- 
Ronald Schoenberg                    fax: 206-727-6521
University of Washington           email: rons@u.washington.edu
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c++
Subject: Re: Pros and cons of C++
Date: 11 Jan 93 19:30:14 GMT
Organization: negligable

In article <TMB.93Jan8152439@arolla.idiap.ch> tmb@idiap.ch writes:
>
>What makes those features costly in C++ is that they need to be
>backwards compatible with C. Backwards compatibility is C++'s greatest
>advantage over competing languages, but it is likely to be its
>eventual downfall.  Safety and garbage collection and many of the
>other features that I mentioned, are features that many programmers
>want, and other languages will sooner or later catch on, languages
>that offer them without the (significant, though not devastating)
>overhead that would be associated with them you tried to support them
>in C++.


I don't know.  I think that eventually there will be a "clean break"
between C & C++, where they will dump backwards compatibility for
some for some of the features mentioned (pointer safety, etc.)

Whether this will be:

	* Compiler options (similar to the current ANSI/K&R compiler
		options found in most C compilers)

	* New language version (C++ 5.0?)

	* A language w/ a new name that is essentially C++ w/ the
		true o-o extensions & features

I can't hazard a guess.  I imagine that one of those is likely
in the next 3-5 years, if not sooner.

	-Richard Hartman
	hartman@ulogic.COM

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"If we shadows have offended, Think but this and all is mended:
 That you have but slumbered here, While these visions did appear.
 And this weak and idle theme, no more yielding but a dream."

Newsgroups: comp.lang.c++
From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
Subject: Re: Reusability will come true bringing by OOP?
Organization: MAXTAL P/L C/- University Computing Centre, Sydney
Date: Tue, 12 Jan 1993 17:02:08 GMT

In article <1993Jan12.042140.27051@sparc4.ncu.edu.tw> oper7@ee05.ncu.edu.tw (Anthony Shih Hao Lee) writes:
>Hi, OOP experters:
>
>These days, My friend and I argued that if reusability will come true
>if we use OOP. Take a example, for those GUI class, if you do not have
>good ability to write good (well-organized, clear) documents, then it
>is impossible for a client to use your classes. Because he cannot
>promise that all behaviors derived from superclass will work correctly.
>so I heard someone write an article (on a magazine) critized C++ is not
>a good OOPL due to it is not well self-explained.
>
>Think about this if you are a TVISION programmers:
>if Borland does not release TVision source code, do you really trust
>the quality of that package?
>

	IMHO reusability will not come from monsters like TV
or whatever, but small, independent, classes, especially
abstract ones.

	GUI classes are the last place to look for this.
Try 'string'. I reuse my string class in almost
every program. It is magic.

	For the moment, I look to using an ADT style
more than OO. One of the main principle of OO and modularisation
in general is to have loose and explicit coupling,
like functions with parameters.

	Inheritance is neither: it provides strong coupling
with implicit interfaces. So it should be treated with
some respect and restraint.

	TV is the sort of heavily integrated nightmare
you get from overdoing OO. I did one program in TV,
and live to regret it.

	Have a look at the Borland template classes (BI classes)
for something I think is much more reusable.


-- 
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
Newsgroups: comp.lang.c++
From: nikki@trmphrst.demon.co.uk (Nikki Locke)
Subject: Re: feedback wanted on appropriate OOPL
Reply-To: nikki@trmphrst.demon.co.uk
Distribution: world
X-Mailer: cppnews $Revision: 1.30 $
Organization: Trumphurst Ltd.
Date: Tue, 5 Jan 1993 17:08:30 +0000

In article <1992Dec30.171527.3534@informix.com> cshaver@informix.com (Craig Shaver) writes:
> Would anyone care to comment on style differences between C++ and
> Smalltalk?  I have seen postings that claim you must approach
> design differently using C++ rather than Smalltalk.  I happen to
> believe that Smalltalk has some good things that the C++ community
> should look at.  

The classic example of style differences between C++ and Smalltalk is the 
typical Smalltalk programmers natural tendency to use heterogenous 
collections. This is not (usually) good C++ style.

[ The following deliberately controversial paragraph should be taken with 
a large pinch of salt, and a few smileys :-]

When Smalltalk programmers start using C++, they often write some kind of 
run-time type identification system in C++ (a base class called "Object" 
is usually a dead giveaway :-). They then rapidly progress to a tree 
structured class heirarchy, with heterogenous collections (look for lots 
of switch statements :-). If they are VERY good, they will actually start 
producing production code (rather than their re-write of the basic
Smalltalk tools they think they need) within the first 6 months, but 
probably not.

I haven't experienced C++ programmers using Smalltalk, but I expect they 
have equal difficulty.

-- 
Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
From: ahumphr@micrognosis.co.uk (Aidan Humphreys)
Newsgroups: comp.lang.c++
Subject: Exception handling
Date: 6 Jan 93 10:33:15 GMT
Organization: Micrognosis, London, UK.

Can anyone provide me with information about execption handling in C++ ?
Is there a good paper or description available anywhere. What compilers 
currently support it? What standards are in place?

My interest is primarily real-time systems where commonly 35% of the code is
dedicated to execption handling.
Newsgroups: comp.lang.c++
From: helz@ecn.purdue.edu (Randall A Helzerman)
Subject: forward declaration of a parameterized type?
Organization: Purdue University Engineering Computer Network
Date: Tue, 5 Jan 1993 03:48:36 GMT

How do you do a forward declaration of a parameterized type?  This sort of
thing doesn't seem to work:

class LinkedList<foo>;

class foo{
public:
	LinkedList<foo> *internal_foo_list;

};
From: sundvall@perrier.se (Mats Sundvall)
Newsgroups: comp.lang.c++
Subject: Re: Template-instantiation fails with referenc
Date: 5 Jan 93 13:07:51 GMT
Reply-To: sundvall@perrier.se
Organization: EMBNet Project Sweden
NNTP-Posting-Host: perrier.embnet.se

In article 726234949@bauv106, stefans@bauv.unibw-muenchen.de (Stefan Schwarz) writes:
>Hi all,
>
>just came to a serious problem with templates. Simple code:
>
>#include <iostream.h>
>template <class T> class Collection
>{
>private:
>        T *_buffer;
>        T _endtag;
>public:
>        Collection (size_t size, T endtag) {
>                _buffer = new T [size];
>                _endtag = endtag; }
>};


       Collection (size_t size, T endtag) : _endtag(endtag) {
               _buffer = new T [size]; }
};


>This fails with:
>line 3: error:  reference member  Collection <Foo&>::_endtag needs initializer

The reference variable _endtag needs an initializr in the constructor. Try the change 
above.

Regrads,

Mats Sundvall
Uppsala University
Uppsala, Sweden
Newsgroups: comp.lang.c++