Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Can element types be the base class? (http://www.velocityreviews.com/forums/t553201-can-element-types-be-the-base-class.html)

PengYu.UT@gmail.com 11-17-2007 10:20 PM

Can element types be the base class?
 
Hi,

I'm wondering if there is any way to use element types as base
classes. Or it is not possible at all?

struct A : public int {
};

Thanks,
Peng

Kai-Uwe Bux 11-17-2007 10:35 PM

Re: Can element types be the base class?
 
PengYu.UT@gmail.com wrote:

> Hi,
>
> I'm wondering if there is any way to use element types as base
> classes. Or it is not possible at all?
>
> struct A : public int {
> };


It's not possible.

You could provide a wrapper template

template < typename T >
class make_base {
...
};

and then do:

struct A : public make_base<int> {
};

But whatever you are trying to accomplish, this probably won't help.


On a related note: what are you trying to accomplish, anyway?


Best

Kai-Uwe Bux


All times are GMT. The time now is 09:37 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.