LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-04-2010, 01:54 PM   #1
vbx_wx
Member
 
Registered: Feb 2010
Posts: 181

Rep: Reputation: 16
function parameter


i have a function parameter that i need it to be a char and also a const char* .
can anyone help me?

Code:
void write(...) // ???
{

}
//..............................
if(somethin)
{
   write('c');
}
else
   write("string");
 
Old 04-04-2010, 02:10 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by vbx_wx View Post
i have a function parameter that i need it to be a char and also a const char* .
can anyone help me?

Code:
void write(...) // ???
{

}
//..............................
if(somethin)
{
   write('c');
}
else
   write("string");
You can do this in C++.
 
Old 04-04-2010, 02:21 PM   #3
vbx_wx
Member
 
Registered: Feb 2010
Posts: 181

Original Poster
Rep: Reputation: 16
yes,but how,what should to parameter type be ? if its const char*,cant pass a char,if its char cant pass a const char*....
 
Old 04-04-2010, 02:23 PM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by vbx_wx View Post
yes,but how,what should to parameter type be ? if its const char*,cant pass a char,if its char cant pass a const char*....

Use web search to find info on

C++ polymorphism

and/or

C++ function signature.
 
Old 04-04-2010, 02:33 PM   #5
vbx_wx
Member
 
Registered: Feb 2010
Posts: 181

Original Poster
Rep: Reputation: 16
ohh,ive got it,i need function overloading
 
Old 04-04-2010, 02:34 PM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by vbx_wx View Post
ohh,ive got it,i need function overloading
And there will be two functions with the same name, but different signature and implementation.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compilation issue when Function is parameter in function call on LINUX sa20358 Linux - Software 2 07-24-2008 10:19 PM
what is function parameter? Jeon, Chang-Min Linux - Software 2 06-22-2006 06:53 PM
Passing one php function result as a parameter to another php function davee Programming 13 09-12-2004 12:08 PM
C: struct as a function parameter zokik Programming 3 12-06-2003 02:52 PM
Bash function parameter Misel Programming 2 05-17-2003 11:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration