🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c++
Article #41

Re: What use is c++ ?

#41
From: keith gorlen
Date: Fri, 28 Feb 1986 17:17
67 lines
3278 bytes
>Hi, my question for all you C++ programmers out there in netland is ...
>
>	"What good is C++ if I already have C ?"
>
>			and
>
>	"What makes' C++ better than C ?"

"C++ is a superset of C that retains the efficiency and notational
convenience of C, while providing facilities for: type checking, data
abstraction, operator overloading, and object-oriented programming."

	- from the back cover of "The C++ Programming Language"

What does this mean? It means that:

If you write: 'fprintf("error in line &d",lnum)', you get an error
message from the compiler instead of a core dump.

You can define new data types of your own, and use them much like the
built-in types; for example, you can easily define a type String to
manage variable-length character strings in the free store.  Then you
can overload the operator "&" to do an inline call to "strcat", overload
the function call operator "()" to do substring extraction, overload the
comparison operators "==", "!=", "<", ">", "<=", and ">=" to do
appropriate inline calls to strcmp, etc.  You can even tell the compiler
how to convert char* strings to and from your own type String.  The
result is that you can write statements like:

	String s, t("abcdef"), u("123");	// declare three Strings
	s = t(0,3) & u;				// s = "abc123"
	s(1,2) = "xy";				// s = "axy123"
	if (s != "abcdef")			// compare s to "abcdef"
		open(s & ".dat",0);		// open the file "axy123.dat"
	cout << s << "\n";			// write "axy123\n" to standard output

The object-oriented programming features (derived classes and virtual functions)
allow you to implement very general data structures and functions (sometimes
called "polymorphic" data structures and functions).  You can easily implement
a general-purpose hash table class, for example, that will work for anything
you would ever care to put in it.  For more information on this style of
programming I would recommend the following references:

Byte, Vol 6 No 8. August 1981. (the SMALLTALK-80 issue)

Brad J. Cox: "Object-Oriented Programming in C" Unix Review, October/November 1983.

Brad J. Cox: "Object-Oriented Programming: A Power Tool for Software Craftsmen"
	Unix Review, February/March 1984.

Brad J. Cox: "Message/Object Programming: An Evolutionary Change in Programming
	Technology" IEE Software.  Vol 1 No 1 January 1984.

[Note: in one of these papers an erroneous statement is made concerning C++ and
dynamic binding.]

And, of course, Bjarne Stroustroup's "The C++ Programming Language"

-- 
---
	Keith Gorlen
	Computer Systems Laboratory
	Division of Computer Research and Technology
	National Institutes of Health
	Bethesda, MD 20892
	phone:	(301) 496-5363
	uucp:	{decvax!}seismo!elsie!cecil!keith
Technical Details
Message-ID: <53@cecil.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!genrad!panda!talcott!harvard!seismo!elsie!cecil!keith
References: <2645@sdcrdcf.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!genrad!panda!talcott!harvard!seismo!elsie!cecil!keith
From: keith@cecil.UUCP (keith gorlen)
Newsgroups: net.lang.c++
Subject: Re: What use is c++ ?
Message-ID: <53@cecil.UUCP>
Date: Fri, 28-Feb-86 12:17:45 EST
Article-I.D.: cecil.53
Posted: Fri Feb 28 12:17:45 1986
Date-Received: Sat, 1-Mar-86 23:42:40 EST
References: <2645@sdcrdcf.UUCP>
Organization: NIH-CSL, Bethesda, MD
Lines: 67