Geeks Talk

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.

Function in C and C++

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...

Go Back   Geeks Talk > Software Development > C and C++
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 12-31-2008
Junior Member
 
Join Date: Dec 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
email2suryaz is on a distinguished road
Question Function in C and C++

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
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-02-2009
Junior Member
 
Join Date: Apr 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
karthik venkat is on a distinguished road
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 ;
}
Reply With Quote
  #3 (permalink)  
Old 02-02-2009
Junior Member
 
Join Date: Jan 2009
Location: pune
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Nisikant is on a distinguished road
Re: Function in C and C++

we have to explicitely type cast the C functions however the C++ compiler can inplicitely typecast the C++ functions.
Reply With Quote
Reply

  Geeks Talk > Software Development > C and C++

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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


All times are GMT -4. The time now is 09:58 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved