Write any small program that will compile in "C" but not
in "C++"

Answer Posted / tareq

<code>
int class;
</code>

$gcc a.c -c; echo $?
0

$g++ a.c -c; echo $?
a.c:1: error: expected identifier before ';' token
a.c:1: error: multiple types in one declaration
a.c:1: error: declaration does not declare anything
1

Is This Answer Correct ?    1 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you write a function that can reverse a linked-list?

579


What is data hiding c++?

605


How does code-bloating occur in c++?

758


What is set in c++?

664


How does work in c++?

603






What problems might the following macro bring to the application?

627


What are the advantages of using typedef in a program?

648


What are the three forms of cin.get() and what are their differences?

636


Write a note about the virtual member function?

610


What is c++ stringstream?

617


What is the use of this pointer in c++?

574


What is the role of copy constructor in copying of thrown objects?

604


What is difference between class and function?

587


Is java easier than c++?

595


I was a c++ code and was asked to find out the bug in that. The bug was that he declared an object locally in a function and tried to return the pointer to that object. Since the object is local to the function, it no more exists after returning from the function. The pointer, therefore, is invalid outside.

616