Re: Dynamic Aggregation
tony_in_da_uk@yahoo.co.uk wrote:
On Jul 25, 9:10 pm, c.gines...@imperial.ac.uk wrote:
I want to create classes that I could aggregate with each others
using operators. This would therefore take the form of a dynamic
aggregation.
I believe "c.ginestet" has a rather unconventional idea of what
"dynamic" means. For whatever reason I've always thought that in
C++ "dynamic" means either "driven by some data in the run-time"
or "having the lifetime not limited by scope". Maybe it's just me...
You might find it useful to search on "multiple inheritance",
basically:
class dog_and_cat : public dog, public cat { };
How is that "dynamic"?
[..impossibility of dog_and_cat existense aside..]
Why do you specifically want to use "+" to do this? You can use
templates to do such things, [..]
Again, how would that be "dynamic"?
I don't question your suggestion of using templates. After all,
we can try writing
template<class T, class U> class from_two : public T, public U
{
// ...
};
template<class T, class U>
from_two<T,U>* operator+(T const& t, U const& u)
{
return new from_two();
}
...
mammal *dogcat = dog + cat; // requires 'mammal' to be
// a virtual base class in both
(or something similar). I am just questioning the use of the
term "dynamic" here. And I second the request to elaborate on the
problem the OP's solving.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask