|
-
May 3rd, 2000, 08:27 AM
#1
Thread Starter
Frenzied Member
I want a class that I can use inside another class, but I want it to be a combination of 2 different classes. both would have the same functions but somewhere in the constructor I'd like to specify which one the class is using.
say my 2 classes are
Code:
class A
{
public:
A(void);
long Fn(void);
};
A::A(void)
{
}
long A::Fn(void)
{
return 10;
}
class B
{
long m_value;
public:
B(long Value);
long Fn(void);
};
B::B(long Value)
{
m_value = Value;
}
long B::Fn(void)
{
return m_value;
}
Now say I want a class C with an overloaded contructor, if I don't include a value in the constructor it inherits a class A, if I do it inherits a class B.
Is that possible?
-
May 4th, 2000, 08:36 AM
#2
How about defining two different constructors and depending on which one you use, you can create an instance of the class that is appropriate.
Something like
class C
{
public:
C(void)
{
A a;
}
C(int in)
{
B a;
}
};
-
May 4th, 2000, 09:34 AM
#3
Thread Starter
Frenzied Member
Right, I was Kinda Hoping on Inheriting them rather than passing all the properties through(I'm including oversimple examples here) oh well
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|