From owner-freebsd-questions@FreeBSD.ORG Tue Nov 11 16:59:48 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3702F16A4CF for ; Tue, 11 Nov 2003 16:59:48 -0800 (PST) Received: from falcon.midgard.homeip.net (h76n3fls24o1048.bredband.comhem.se [213.67.148.76]) by mx1.FreeBSD.org (Postfix) with SMTP id 2D0A643FBF for ; Tue, 11 Nov 2003 16:59:46 -0800 (PST) (envelope-from ertr1013@student.uu.se) Received: (qmail 90587 invoked by uid 1001); 12 Nov 2003 00:59:44 -0000 Date: Wed, 12 Nov 2003 01:59:44 +0100 From: Erik Trulsson To: Chris Howells Message-ID: <20031112005944.GA90535@falcon.midgard.homeip.net> Mail-Followup-To: Chris Howells , freebsd-questions@freebsd.org References: <200311102314.hAANEpc25533@clunix.cl.msu.edu> <200311111403.13202.howells@kde.org> <448ymmcxv8.fsf@be-well.ilk.org> <200311120028.32412.howells@kde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200311120028.32412.howells@kde.org> User-Agent: Mutt/1.5.4i cc: freebsd-questions@freebsd.org Subject: Re: Another Newbie Question: C or C++ X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Nov 2003 00:59:48 -0000 On Wed, Nov 12, 2003 at 12:28:32AM +0000, Chris Howells wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi, > > On Tuesday 11 November 2003 23:02, Lowell Gilbert wrote: > > > each other. [There is a myth that C++ is a superset of C, but this is > > not really the case.] > > C++ is based on C. Any C code (providing it does not use certain key word that > are reserved in C++) can be compiled in a C++ compiler. Wrong. C++ is based on C, but it has made some changes so it is not quite a superset of C. Try for example the following little program: #include int main(void) { char *a; a=malloc(10); if(a) free(a); return 0; } This is valid C, but not valid C++. (C++ does not perform automatic conversion between void pointers and other pointers.) This should suffice to demonstrate that C++ is not really a superset of C. The intersection between C and C++ is a usable programming language though, but it is rarely worth the trouble to restrict oneself to that subset of the languages. -- Erik Trulsson ertr1013@student.uu.se