function overloading (cont.) = = "function overloading with function pointers

Source: Internet
Author: User

function overloading and function pointers (this piece is important, follow up to continue learning):

When you assign a value to a function pointer using the overloaded functions name

Selecting candidates that are consistent with the parameter list of a function pointer based on overloaded rules

The function types that match the candidate's function type and function pointer strictly

#include  <iostream>using namespace std;void myfunc (int a) {     printf ("a:%d\n", a);} Void myfunc (char *p) {    printf ("p:%s\n", p);} Void myfunc (int a,int b) {    printf ("a:%d\n", a);} function pointers   Underlying syntax//1  declares a function type//void myfunc (int a,int b) typedef void  (Mytypefunc) (int a,int b);//mytypefunc *myfuncp = null;//defines a pointer to a function that points to the entry address of the function//2  Declares a function pointer type typedef void  (*MYPTYPEFUNC) (int a,int b);//Declares a pointer function type//MYPTYPEFUNC&NBSP;FP  = null;   //defines a function pointer by using the function pointer type   defined//3  a function pointer   variable void  (myvarpfunc) ( INT&NBSP;A,INT&NBSP;B); Int main (int argc, char *argv[]) {     Myptypefunc fp = null;    fp = myfunc ();     FP (;    cout << ) "hello world!"&NBSP;&LT;&LT;&NBSP;ENDL;&NBSP;&NBSP;&NBSP;&NBSP;RETURN&NBSP;0;} 




Note Distinguishing function overloading overrides redefinition

This article is from the "11907685" blog, please be sure to keep this source http://11917685.blog.51cto.com/11907685/1893303

function overloading (cont.) = = "function overloading with function pointers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.