I got a code in the net.
I executed that one , it is working fine..I did not understand how it is working..
can anybody explain me?
code is..
c12.h
Code:
#ifndef C12_H
#define C12_H
#include <iostream.h>
class C1 {
public:
void f1( int arg = 0 ) {cout<<"inside f1"<<endl;}
//
};
class C2 {
public:
void f2() {cout<<"inside f2"<<endl;}
void f2( int) {cout<<"inside f2(int)"<<endl;}
// ...
};
#endif
Code:
// Failure to Distinguish Overloading from Default Initialization
#include "c12.h"
int main() {
C1 c1;
c1.f1(0);
c1.f1();
C2 c2;
c2.f2(0);
c2.f2();
//void (C1::*pmf1)() = &C1::f1; //error!
void (C2::*pmf2)() = &C2::f2;
return 0;
}
Regards,
sharmila.

