小编chr*_*ris的帖子

使用值列表初始化模板数组

在标准 C++ 中我们可以这样写:

int myArray[5] = {12, 54, 95, 1, 56};
Run Code Online (Sandbox Code Playgroud)

我想用模板写同样的东西:

Array<int, 5> myArray = {12, 54, 95, 1, 56};
Run Code Online (Sandbox Code Playgroud)

假如说

template <class Type, unsigned long N>
class Array
{
public:

    //! Default constructor
    Array();

    //! Destructor
    virtual ~Array();

    //! Used to get the item count
    //! @return the item count
    unsigned long getCount() const;

    //! Used to access to a reference on a specified item
    //! @param the item of the item to access
    //! @return a reference …
Run Code Online (Sandbox Code Playgroud)

c++ arrays templates

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

arrays ×1

c++ ×1

templates ×1