为什么这个c++函数是结构体
Why this c++ function is a struct
我正在学习c++,并且对使用信任库的c++代码有点困惑。以下是我的问题:
- 为什么使用关键字
struct
-
为什么函数
is_word_start
有冒号部分::public thrust::binary_function"// determines whether the right character begins a new word struct is_word_start : public thrust::binary_function<const char&, const char&, bool> { __host__ __device__ bool operator()(const char& left, const char& right) const { return is_alpha(right) && !is_alpha(left); } };
- struct的含义与class几乎相同,只是默认情况下struct的所有成员都是public,而在class中它们是private。(你可以像在类中那样在结构中指定访问修饰符。)
-
: public
部分表示公共继承。你应该好好研究一下这个和其他的继承类型。
该类重载一个所谓的调用操作符,因此该类的对象可以作为函数调用(在本例中带有两个实参)。这样的对象通常被称为函子,并在stl和其他任何地方广泛使用。
相关文章:
- 如何在构造函数中初始化结构体的动态数组?
- C++ 使用成员函数返回结构体指针属性的值
- 在使用结构体和用函数填充其变量(使用指针)时遇到问题
- 通过函数参数确定结构体成员
- 如何使用其他函数返回的值为结构体成员赋值
- 在不使用 std::copy 函数的情况下编写这个复杂的复制结构体
- 如何调用一个函数,它在一个单独的类中打印出一个结构体数组
- 如何使用结构体作为接口从函数返回指向数组的指针
- 为什么这个c++函数是结构体
- 将结构体传递给函数以编辑数组导致的c++ seg错误
- 调用返回结构体的c++ DLL函数
- 如何创建一个公共python函数,它可以接收c++结构体/实例或python对象作为参数
- 被视为依赖作用域的函数模板的函数作用域结构体的静态成员函数
- c++结构体是否有默认构造函数?
- 将结构体传递给c++函数(效率)
- 具有许多参数的函数——将它们作为结构体
- 无法将结构体数组传递给函数
- 从通过函数发送的结构体中复制数组
- 从c#调用c++函数-结构体,指针,函数指针
- 指向结构体作为函数参数的指针-为什么不更新其值