Monday, July 9, 2007

Is there something we can do in C but not in C++?

I have a really funny answer

Declare variable names that are keywords in C++ but not C.


#include < stdio.h >
int main(void)
{
int old, new=3;
return 0;
}


This will compile in C, but not in C++!

12 comments:

HeavenFliers said...

isn;t this a stupid question

Anonymous said...

yep, sounds stupid but tricky though. Btw good reply

Anonymous said...

main()
{
const int a;
printf("%u",&a);
}
this cprogram will compile in turboc++
#include"iostream.h"
void main()
{
const int a;
cout<<&a;
}
this c++program will not compile in turboc++.

Anonymous said...

1)We can assign any type of pointer to void pointer without cast in c but not in c++.
2)
int main()
{
const int i;
}

will not give error in c but in c++.

Sumi said...

In c++ We must initlize the const variable .
You can try with const int a=0
Might will work

Sumi said...

In c++ We must initlize the const variable .
You can try with const int a=0
Might will work

Anonymous said...

The "designated initializer" syntax in ISO C99 is not available in C++.

http://stackoverflow.com/questions/1601201/c-struct-initialization-using-labels-it-works-but-how-documentation

http://gcc.gnu.org/onlinedocs/gcc-4.4.1/gcc/Designated-Inits.html#Designated-Inits

Anonymous said...

Hello! I simply wish to give you a big thumbs up for your excellent information
you have right here on this post. I'll be coming back to your site for more soon.

Here is my web-site - metabolic rate calculator

soysoy said...

I definitely liked reading everything that is posted on your website. Where else could anyone get that type of facts in such a perfect way of writing?

www.triciajoy.com

ed medication said...

Your method of describing everything in this article is in fact pleasant, every one can easily be aware of it, Thanks a lot.

erectile dysfunction drug said...

Excellent blog here! Also your website loads up fast! What host are you using? Can I get your affiliate link to your host? I wish my website loaded up as fast as yours lol

best ed pills said...

Excellent post. I was checking constantly this blog and I'm impressed! Very useful info specially the last part :) I care for such information much. I was seeking this particular info for a very long time. Thank you and good luck.