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

Answer Posted / murali

hi(){ }

g++ -x c++ -c test1.cpp
test1.cpp:1: ISO C++ forbids declaration of `hi' with no
type

gcc -x c -c test1.cpp
Here the default return type is int.

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is scope resolution operator in c++ with example?

563


How do you invoke a base member function from a derived class in which you’ve overridden that function?

586


What do nonglobal variables default to a) auto b) register c) static

652


When do we run a shell in the unix system? How will you tell which shell you are running?

558


How much maximum can you allocate in a single call to malloc()?

637






what are Operators and explain with an example?

711


What is general form of pure virtual function? Explain?

515


What is the difference between a declaration and a definition?

584


How can you prevent accessing of the private parts of my class by other programmers (violating encapsulation)?

648


What are move semantics?

675


Can we make any program in c++ without using any header file and what is the shortest program in c++.

617


What is else syntax in c++?

642


Why do we use using namespace std in c++?

605


Do you know the problem with overriding functions?

574


What is new in c++?

582