Doug wrote:
> Igore didn't mean there is no difference between C and C++.  He was just
> saying a 'project' isn't C or C++.  In other words, C and C++ have different
> (though similar) compiler rules, syntax, etc.  By default, the compiler will
> compile a '.c' file using the C rules, and a '.cpp' file with the C++ rules.
> And you can mix .c and .cpp files in the same project.
>
> As for what the difference is?  That's a big question.  Objects exist in
> C++, and they don't in C.  That's the tip of the iceberg.
> Doug
>   

It depends on your definition of "object".  I hate to nit-pick, but for
me, "object" may
contain data or code or both data and code.  So with this definition, C
implements objects
without code.

For example, in C, a "struct" is a template used to instantiate objects
which only implement data,
whereas in C++, a "struct" is a template used to instantiate objects
which implements both data and code.

You can just replace the "class" keyword with "struct":

Compiles only with C++:

struct foo {
  int a;
  void m() {int b=0; b++;}
};

Compiles with both C and C++ compilers:

struct foo {
  int a;
  /*void m() {int b=0; b++;}*/
};

Of course, in addition to template classes, C++ has (generic) class
templates and many other features, as you stated.

   -Chris






> -----Original Message-----
> From: sqlite-users-boun...@sqlite.org
> [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Bob Keeland
> Sent: Tuesday, November 30, 2010 5:02 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] Just compiled SQLite in Visual Studio
>
> OK then I have a newbee question that is actually out of the scope of
> SQLite. If the only difference between C and C++ is the file extension, then
> what is the difference between C and C++? I'm thinking of adding a language
> other than the Visual Basic that I kind of know and would like to know the
> difference. I've been thinking about Java, but am not sure yet.
> Bob Keeland
>
> --- On Tue, 11/30/10, john darnell <john.darn...@walsworth.com> wrote:
>
>
> From: john darnell <john.darn...@walsworth.com>
> Subject: Re: [sqlite] Just compiled SQLite in Visual Studio
> To: "General Discussion of SQLite Database" <sqlite-users@sqlite.org>
> Date: Tuesday, November 30, 2010, 10:25 AM
>
>
> Thanks Igor.
>
> -----Original Message-----
> From: sqlite-users-boun...@sqlite.org
> [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Igor Tandetnik
> Sent: Monday, November 29, 2010 7:11 PM
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] Just compiled SQLite in Visual Studio
>
> john darnell <john.darn...@walsworth.com> wrote:
>   
>> I just added it to a Visual Studio 8 project, turned off the use of 
>> precompiled headers (the project is a C++ project) and compiled the
>>     
> SQLite.c file without any errors.
>
> There is no such thing as a C++ project. A project in Visual Studio can
> happily contain both C and C++ files. By default, file extension determines
> whether the file is compiled with C or C++ compiler (.c would indicate C),
> and this could also be overridden in project settings on a per-file basis.
> --
> Igor Tandetnik
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>
>
>       
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
> __________ Information from ESET NOD32 Antivirus, version of virus signature
> database 5662 (20101130) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>   
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to