Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Nov 2003 01:59:44 +0100
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        Chris Howells <howells@kde.org>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Another Newbie Question: C or C++
Message-ID:  <20031112005944.GA90535@falcon.midgard.homeip.net>
In-Reply-To: <200311120028.32412.howells@kde.org>
References:  <200311102314.hAANEpc25533@clunix.cl.msu.edu> <200311111403.13202.howells@kde.org> <448ymmcxv8.fsf@be-well.ilk.org> <200311120028.32412.howells@kde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <stdlib.h>
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.


-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031112005944.GA90535>