Program for function pointer in C++
Program for function pointer in C++
#include<iostream>
using namespace std;
class Data
{
public: //access specifier
int fun(float) // function defination
{
cout<<"object created"; //prints the msg between ""
return 10;
}
}; //end of the class
int main()
{
int (Data::*fp2)(float);
Data obj;
fp2=&Data::fun;
cout<<(obj.*fp2)(11.1);
}
Output:
object created
10
Comments
Post a Comment