如何创建线程类的子类? [英] How to create a subclass of thread Class ?

查看:124
本文介绍了如何创建线程类的子类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

class MyThread: public thread
{
    MyThread(_Callable&& __f, _Args&&... __args) : thread(__f, __args);
};

不起作用,在

not works, not see _Callable and _Args

.com / questions / 19210120 / how-to-create-a-subclass-of-thread-class-proper-in-csubclass-of-stdthread">
http://stackoverflow.com/questions/19210120/如何创建一个子类的线程类正确的csubclass-of-stdthread


in http://stackoverflow.com/questions/19210120/how-to-create-a-subclass-of-thread-class-properly-in-csubclass-of-stdthread

是不同的

is differ

推荐答案

在4月14日下午6:33,Borneq写道:

On 4/12/2017 6:33 PM, Borneq wrote:


如何创建线程类的子类?

How to create a subclass of thread Class ?

为什么你认为你需要它?你希望实现什么? std :: thread并非旨在派生自。

Why do you think you need that? What do you hope to achieve? std::thread wasn't designed to be derived from.


class MyThread: public thread
{
        MyThread(_Callable&& __f, _Args&&... __args) : thread(__f, __args);
};

不起作用,看不到_Callable和_Args

not works, not see _Callable and _Args

你需要一个构造函数是一个模板。 _Callable和_Args将是它的模板参数。

You need a constructor that is a template. _Callable and _Args would be its template parameters.


这篇关于如何创建线程类的子类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆