C++怎么在类中声明一个容器成员啊

问题遇到的现象和发生背景

C++为什么不能在类中声明一个容器啊?

class Test
{
public:
    deque<int> deq;
    deq.push_back(1);
};
运行结果及报错内容

Unknown type name 'deq'

img

deque<int> deq;
class Test
{
    deq d = deq;//为什么这样是可以的?
}

怎么才能在类中声明一个deque或者其他容器的成员啊各位

你这一句

deq.push_back(1);

不能作为成员呀,这是一个语句,你为啥在类里面执行