Re: Practical applications on C++
On Jul 22, 1:53 pm, ManicQin <Manic...@gmail.com> wrote:
On Jul 20, 10:58 am, James Kanze <james.ka...@gmail.com> wrote:
I'm not sure what all this business of "if you don't use X, it's
not C++" is supposed to mean. That <vector> isn't C++, because
it doesn't use polymorphism? C++ provides a very large number
of features, to support many different paradigms. If you don't
use some feature, because some other paradigm is more
appropriate for the problem, you're still using C++.
I agree with you but what I meant is if I write:
//snip
#include <stdio.h>
void main()
{
printf("hello world");}
//
and compiling it in an c++ compiler is it a c++ program or a
c? (I gave a bit exaggerated example) it's a c syntax but c++
will have no problem compiling it (except the void main()
warning )
Well, it's not a legal program in either language; both
languages require the return type of main to be int. (C allows
the compiler to support void main() as an extension, C++
requires a diagnostic. And if you change the return type to
int, falling of the end of a function which returns a value is
undefined behavior in C.)
Other than that: if you put the code in a file with an extension
.cpp or .cc, it's a C++ program. In such simple cases, you
can't tell the difference, but typical C won't compile with a
C++ compiler (and vice versa, of course).
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34