hello,
I understand the alternative but not why I shouldn't use pointertomembers.
Anyway: What do you suggest for this case? The same?
class A {
public:
trasformData1() { ......}
trasformData2() {..........}
trasformData3() { .....}
//maybe here is better use another enum and one "TrasformData(enum);" ? I mean in the same way below....
//trasFormData1,2,3 here are very different
};
class B {
vector<A> _va;
enum trasf { trasf1, trasf2, trasf3; }
public:
void trasform( trasf n) {
switch (n) {
case trasf1 :
//loop on _va and call "_va.trasformData1();"
break;
case trasf2 : "call _va.trasformData2();" break;
case trasf3 :"call _va.trasformData3();" break;
default: exit(-1) //error
};
}
};
//main.cpp
B b;
//fill the vector
//the type of trasformation is chose at command line
b.trasform(B::Trasf1);
class A {
public:
trasformData1() { ......}
trasformData2() {..........}
trasformData3() { .....}
//maybe here is better use another enum and one "TrasformData(enum);" ? I mean in the same way below....
//trasFormData1,2,3 here are very different
};
class B {
vector<A> _va;
enum trasf { trasf1, trasf2, trasf3; }
public:
void trasform( trasf n) {
switch (n) {
case trasf1 :
//loop on _va and call "_va.trasformData1();"
break;
case trasf2 : "call _va.trasformData2();" break;
case trasf3 :"call _va.trasformData3();" break;
default: exit(-1) //error
};
}
};
//main.cpp
B b;
//fill the vector
//the type of trasformation is chose at command line
b.trasform(B::Trasf1);
To copy to clipboard, switch view to plain text mode
Bookmarks