Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how does a main() in C++ is different from main() in C?

Answer Posted / yj

First of all, make it clear that whenever we run any program the compiler search for the main() function to start execution...
Now,
The programming language C follows top down approach. Means the control moves from top to down. Hence in this we have to give main function above all the other lines of code...
But when you program in C++ which follows bottom up approach i.e., the control moves from bottom to up...For example, when we make a function in C++ we give its definition above main() and when we call that function in main(): as soon as the compiler encounter the "calling line"...the compiler now search for the definition of that function which is above the function main(). Now u visualise that the control is moving from bottom to up.

Hence,
"The function main() in C has to be given at the top. But in C++the function main can be at the bottom also"

Is This Answer Correct ?    25 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

can inline function declare in private part of class?

4500


What are constructors in oop?

1282


Can we create object of abstract class?

1150


How do you define social class?

1117


What is the oops and benefits of oops programming?

1031


Why is abstraction used?

1139


What is encapsulation and abstraction? How are they implemented in C++?

1188


What is oops and its features?

1152


Why do we use inheritance?

1193


Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.

2243


What is ambiguity in inheritance?

1172


Why is polymorphism used?

1088


Why is it so that we can have virtual constructors but we cannot have virtual destructors?

5054


Explain the advantages of inheritance.

1196


What is stream in oop?

1361