编程语言
首页 > 编程语言> > C++ 结构体、模板、类、重载初使用

C++ 结构体、模板、类、重载初使用

作者:互联网

目的:需要几个缓存用的数组900*750

首先定义一个模板<参数数据类型,参数1,参数2>

定义一个class类 名字自己取ap_uint0

下面是公用的数组模板[lrow][lcol]

下面是一个取值的操作函数[](索引)

{返回索引当前值}

template <typename T, int32_t LROW, int32_t LCOL> class ap_uint_0{ public:   T M_D[LROW][LCOL];
T* operator [](int index) { return M_D[index] ; } }; -----------------------------------------------------     typedef ap_uint_0<int8_t,900,750> D_done_buffer; D_done_buffer D_done; D_done_buffer D_done_row; D_done_buffer D_done_col; 定义了三个相同模板的数组,后面就可以使用了   .函数、结构体、类 模板的 定义 //函数模板---使用体现:调用函数时传递的参数类型。 template<class 数据类型参数标识符> <返回类型><函数名>(参数表) { 函数体 }   //结构体模板---使用体现:声明结构元素时 StackNode<类型> s; template<class T> struct StackNode {   struct T data;   struct StackNode<T> *next; };

标签:struct,buffer,C++,ap,done,StackNode,重载,模板
来源: https://www.cnblogs.com/leebin7777/p/11670294.html