F
FefeOxy
Hi,
This is a hypothetical thing that I want to test out, and if it works,
I will be using it to enhance my code.
// --- Suppose I have an abstract base class: ---
class A {
public:
A(void) { }
virtual A(void) { }
//...some virtual functions....
virtual void vFunc(int n)=0;
};
// --- and 2 class that inherits it.. .---
class B : public A {
public:
//....constructors, destructors, other functions....
enum _E_ { P=1, Q, R };
void vFunc(int n);
} ;
class C : public A {
public:
//....constructors, destructors, other functions....
enum _E_ { P=5, Q, R };
void vFunc(int n);
} ;
// --- Main ---
int Main (void) {
B *objB = new B();
C *objC =new C();
A *p = objB;
p->vFunc(P);
p = objC;
p->vFunc(P);
//......some other stuff + delete.......
} //main
Questions:
1. Can you actually do this?
2. will the value of P be correct? (in class B it'd be 1, in class C
it'd be 5)
Thanks everyone!
This is a hypothetical thing that I want to test out, and if it works,
I will be using it to enhance my code.
// --- Suppose I have an abstract base class: ---
class A {
public:
A(void) { }
virtual A(void) { }
//...some virtual functions....
virtual void vFunc(int n)=0;
};
// --- and 2 class that inherits it.. .---
class B : public A {
public:
//....constructors, destructors, other functions....
enum _E_ { P=1, Q, R };
void vFunc(int n);
} ;
class C : public A {
public:
//....constructors, destructors, other functions....
enum _E_ { P=5, Q, R };
void vFunc(int n);
} ;
// --- Main ---
int Main (void) {
B *objB = new B();
C *objC =new C();
A *p = objB;
p->vFunc(P);
p = objC;
p->vFunc(P);
//......some other stuff + delete.......
} //main
Questions:
1. Can you actually do this?
2. will the value of P be correct? (in class B it'd be 1, in class C
it'd be 5)
Thanks everyone!