have you encountered this type of expression in your code :-
int a:3;
what is this :3 stand for, these are called the bit fields, you can learn more about it here
have you encountered this type of expression in your code :-
int a:3;
what is this :3 stand for, these are called the bit fields, you can learn more about it here
please visit following link http://www.altdevblogaday.com/2012/04/26/functional-programming-in-c/
Visual Studio generally hide complexity of different compiler options from the programmer, though MSVC compiler provides you different compiler options to play with your resulting application.
Now all the compiler options are listed here and to turn them ON follow these steps (IN VS2010, probably would be available in VS2008 at same location):-
Read more about this here
In continuation with my last post, where we followed generalized approach to create function pointer array having same signature. we can’t follow same creating function pointer array having different signature. So our approach would be to create hollow body i.e. void* in C++ and object class in C#, add our function address to them and at the time of calling cast them to appropriate function signature and call the function.
here is the code what i have written:-
#include <vector>
using namespace std;
typedef void (*MySingleArgFunction) (int);
typedef void (*MyDoubleArgFunction) (int,int);
void Function1(int i)
{
cout<<"Hello in Function 1 Number " <<i<<endl;
}
void function2(int i)
{
cout<<"Hello in Function 2 Number " <<i<<endl;
}
void function3(int i,int j)
{
cout<<"Hello in Function 3 Number " <<i<<j<<endl;
}
//in calling function
// using MFC Class
CPtrArray myarr;
myarr.Add((void*)&Function1);
myarr.Add((void*)&function2);
myarr.Add((void*)&function3);
((MySingleArgFunction)myarr.GetAt(0))(10);
((MySingleArgFunction)myarr.GetAt(1))(20);
((MyDoubleArgFunction)myarr.GetAt(2))(30,40);
// Using STL Class
vector<void*> mutiplesigVec;
mutiplesigVec.push_back(&Function1);
mutiplesigVec.push_back(&function3);
((MySingleArgFunction)mutiplesigVec[0])(10);
((MyDoubleArgFunction)mutiplesigVec[1])(30,40);