Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on Function in C and C++ within the C and C++ forums, part of the Software Development category; What is the difference in using a function in c and C++. C++ asks for a prototype declaration while in C no such Question is asked by the compiler...
|
|||||||
|
|||
|
Re: Function in C and C++
Both in c and c++ prototype declaration for functions is required but it is not mandatory....
1. if u define your function before main() then no need to define prototype cos function definition provides the prototype. ex: #include<iostream.h> void display() { cout<<"hi c++"<<endl; return ; } int main() { void display(); display(); return 0; } 2.if u define your function after main(), then you can declare the prototype at the point where you call the function or before main() ex: #include<iostream.h> int main() { void display(); //function prototype before calling the function display(); return 0; } void display() { cout<<"hi C++"<<endl; return ; } or #include<stdio.h> void display(); //function prototype before main() int main() { display(); return 0; } void display() { cout<<"hi C++"<<endl; return ; } |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Function | geeta90210 | QTP | 2 | 08-18-2008 04:34 AM |
| @function | anil.curse | Data Warehousing | 0 | 07-28-2008 10:03 AM |
| throwexception from function to function | JobHelper | VB.NET | 1 | 06-25-2007 07:24 AM |
| pl/sql function | gujjar | Oracle Certification | 3 | 02-22-2007 10:47 AM |
| TSL Function | sutnarcha | WinRunner | 1 | 12-20-2006 05:40 AM |