Which derived class is it?
From: Brad Marts (marts_at_phy.duke.edu)
Date: 12/15/03
- Next message: osmium: "Re: What to learn?"
- Previous message: tom_usenet: "Re: Is there a reference counted implementation of std::vector?"
- Next in thread: jeffc: "Re: Which derived class is it?"
- Reply: jeffc: "Re: Which derived class is it?"
- Reply: David Harmon: "Re: Which derived class is it?"
- Reply: Deming He: "Re: Which derived class is it?"
- Reply: Jeff Schwab: "Re: Which derived class is it?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 15 Dec 2003 10:34:48 -0700
I would like to have a function that takes as an argument a base class but
performs differently depending on which type of derived class is passed.
Can I tell which derived class is passed?
For example:
class Base
{ //...
};
class D1: public Base
{ //...
};
class D2: public Base
{ //...
};
void f(Base b)
{
// Do one thing if b is of type D1, Do another if b is of type D2
}
Is this the right idea? Or do I have to write multiple copies of f()
with arguments overloaded with the derived classes?
Brad
- Next message: osmium: "Re: What to learn?"
- Previous message: tom_usenet: "Re: Is there a reference counted implementation of std::vector?"
- Next in thread: jeffc: "Re: Which derived class is it?"
- Reply: jeffc: "Re: Which derived class is it?"
- Reply: David Harmon: "Re: Which derived class is it?"
- Reply: Deming He: "Re: Which derived class is it?"
- Reply: Jeff Schwab: "Re: Which derived class is it?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|