在类中使用vs typedef

时间:2019-07-10 08:54:44

标签: c++ c++11 typedef using using-declaration

我认为C ++ 11和using中新的typedef语法是等效的(模板除外)。但是似乎使用using也不可能声明一个类成员。

class A {
   //... Public members 
private:
    typedef std::vector<double> vector_double; 
    using vector_int = std::vector<int>;        

    void bar(vector_double& vecDouble); // type can be used
    void foo(vector_int& vecInt); // type can't be used: synatx error
 // ... Possible other private members
}

当我尝试在类A的成员函数之一中使用类型vector_int时,出现编译器错误:syntax error: identifier 'vector_int'

我在这里做错什么了吗?还是无法使用using定义成员类型?

0 个答案:

没有答案