Hi
I have probleam while while initilazing nested class ...
I needs to create a object 'b' of B(nested class) in A(surrounding class).
while constructing b I have to pass pointer of funtion in Class A.
But when I am doing this compilr throws error.
Please helpe me to solve this problem...
here is the code...
#include<iostream.h>
#include<stdlib.h>
class A {
int j;
public:
class B {
int i ;
public:
B(){
cout<< "B is created \n";
}
B(void (*pf)()) {
cout<< "B is created....funp \n";
}
B(int i) {
cout<< "B is created...i \n";
}
void printB() {
cout<<"hai..B";
}
};
static int i;
B b;
B c;
A():b(show),c(j){ // <=======error is here
}
A(void (*pf)()) {
}
void show () {
cout<<"hello";
}
};
void show () {
cout<<"hello";
}
int main() {
int i;
A o(show);
A c(show);
A a;
}
Nabil.