🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Harry W. Reed Wed, 26 Feb 1986 07:48
What use is c++ ?
#29
Author: Harry W. Reed
Date: Wed, 26 Feb 1986 07:48
11 lines
889 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 ?"


        Harry Reed
        {allegra, ihnp4, cbosgd, hplabs, burdvax}!sdcrdcf!doon
Re: What use is c++ ?
#41
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads