Template bugged?

Patrick Kreft patrick_kreft at gmx.net
Tue Sep 18 13:28:18 PDT 2007


Patrick Kreft schrieb:
> BCS schrieb:
>> Reply to Patrick,
>>
> ....
>>
>> I think that would also fail in C++. If not, than the difference is 
>> not a template issue. The issue is that a class news an instance of 
>> it's self for each instance of it's self. It's just hidden by the use 
>> of template base classes
>>
>>
> 
> Hmm it's work well on MinGW.
> 
> #include <iostream>
> 
> using namespace std;
> 
> class windows {
> public:
>     void msgloop() {
>         std::cout << "MsgLoop" << std::endl;
>     }
> };
> 
> template <class app, class subsystem = windows>
> class application {
> public:
>     int execute() {
>         _app->run();
>         _subsystem->msgloop();
>         return 0;
>     }
> public:
>     subsystem * _subsystem;
>     app * _app;
> };
> 
> class HelloWorld : public application<HelloWorld> {
> public:
>     void run() {
>         std::cout << "HelloWorld" << std::endl;
>     }
> };
> 
> int main() {
>     HelloWorld app1;
>     app1.execute();
>     std::cin.get();
>     return 0;
> }


ops i forget somewhat, nvm. and thx for help :)



More information about the Digitalmars-d mailing list