EDA, Software and Business of technology
Greek, 'loxos: slanting. To displace or remove from its proper place
da·tums A point, line, or surface used as a reference
... disruption results in new equilibria
#include <stdio.h>
typedef int (*myFunc)(int a, int b);
int func1(int a){
printf("In func1 \n");
}
int func2(int a, int b){
printf("In func2 \n");
}
void executeFunc(myFunc someFunc ){
//void executeFunc(void* someFunc ){
myFunc actualFunc=someFunc;
actualFunc(1,2);
//actualFunc(1,2);
}
main(){
executeFunc((myFunc)func1);
}
#include <stdio.h>
typedef int (*myFunc)(int a, int b);
int func1(int a){
printf("In func1 \n");
}
int func2(int a, int b){
printf("In func2 \n");
}
void executeFunc(myFunc someFunc ){
//void executeFunc(void* someFunc ){
myFunc actualFunc=someFunc;
actualFunc(1,2);
//actualFunc(1);
}
main(){
executeFunc((myFunc)func2);
}
If the expression that denotes the called function has a type that includes a prototype, the number of arguments shall agree with the number of parameters
#include <stdio.h>
int func3(int a){
return 1;
}
main(){
func3(1,2,3);
}
#include <stdio.h>
int func3(){
return 1;
}
main(){
func3(1,2,3);
}
#include <iostream>
using namespace std;
class A{
public:
A() {_i=5;}
~A(){cout<<"Destroying A"<<endl;}
int _i;
};
class B: public A{
public:
B() {}
~B(){cout<<"Destroying B"<<endl;}
};
main(){
A a( B() );
cout<<a._i;
}
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Functor1{
public:
void operator ()(int i){ }
};
main(){
vector<int> vv;
for_each(vv.begin(), vv.end(), Functor1());
}
//A a=A( B() );
#include <iostream>
void f(int i) { std::cout << "int=" << i << '\n'; }
void f(short s) { std::cout << "short=" << s << '\n';}
int main()
{
f(1); // calls f(int)
void f(short);
f(1); // fooled you!
}
#include <iostream>
class X{};
void f(X x, int i) { std::cout << "int=" << i << '\n'; }
void f(X x, short s) { std::cout << "short=" << s << '\n';}
int main()
{
X x1;
f(x1,1); // calls f(int)
void f(X x, short);
f(x1,1); // fooled you!
}