Topic: virtual in template Base class


Author: Michael Entin <michen@microsoft.com>
Date: Sun, 24 Dec 2000 03:24:58 CST
Raw View
No, you can't add virtual at the this moment - virtual is not part of the
type.

However, if you want to get two different Test's classes - one with virtual
Test2 and another with non-virtual Test2, use extra class:

template<class virtualBase>
class Mediator : virtual virtualBase
{
};

Now you can have both
Test<Test2> testWithNonVirtualTest2;
and
test<Mediator<Test2> > testWithVirtualTest2;

Michael Entin
Brainbench MVP Team, http://www.brainbench.com/

> "Claude Quezel" <Claude_Quezel@Syntell.corba>
> wrote in message news:<3A1027B8.D987EECA@Syntell.corba>...
>
> Is it legal to use "virtual" in template parameters as example below?
>
> class Test2 {
> };
>
> template<class Base>
> class Test : public Base {
> };
>
> Test<virtual Test2> test;
>
>
> --
>
> Claude Quezel (claude_quezel@syntell.corba)
> anti-spam: replace corba by com in private replies

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]





Author: "Claude Qu zel" <Claude_Quezel@Syntell.corba>
Date: 2000/11/13
Raw View
Is it legal to use "virtual" in template parameters as example below?

class Test2 {
};

template<class Base>
class Test : public Base {
};

Test<virtual Test2> test;


--

Claude Qu=E9zel (claude_quezel@syntell.corba)
anti-spam: replace corba by com in private replies


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: Ron Natalie <ron@sensor.com>
Date: 2000/11/13
Raw View

"Claude Qu=E9zel" wrote:
>=20
> Is it legal to use "virtual" in template parameters as example below?
>=20
> class Test2 {
> };
>=20
> template<class Base>
> class Test : public Base {
> };
>=20
> Test<virtual Test2> test;
>=20
No.  Virtual is not part of the type.  Templates aren't just preprocessor
macros.  You can't put public or private in there either.   Why do you th=
ink
you need to do this?

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]