c++ - 如何在 hpp 文件中实现类函数?
问题描述
我有一个名为 arra2d.h 的文件,其中包含 Array2D 类的定义,如下所示:
namespace math
{
template <typename T>
class Array2D
{
protected:
std::vector<T> buffer;
unsigned int width, height;
public:
const unsigned int getWidth() const;
const unsigned int getHeight() const;
T* getRawDataPtr();
void setData(const T* const& data_ptr);
T& operator () (unsigned int x, unsigned int y);
Array2D(unsigned int width = 0, unsigned int height = 0, const T* data_ptr = 0);
Array2D(const Array2D& src);
~Array2D();
Array2D& operator = (const Array2D& right);
};
} //namespace math
/#include array2d.hpp
我想在另一个名为 array2d.hpp 的文件中实现所有功能,你应该怎么做?功能定义如何?谢谢你。
解决方案
推荐阅读
- php - 使用 Laravel 和 PHP 制作文本文件
- java - 如何保证施工阶段初始化所有实体的计划变量?
- azure - 如何将 Web 服务器和应用服务器迁移到 azure?
- elixir - 在更改集属性进入数据库之前对其进行转换
- javascript - 动态日期封锁 jquery datepicker
- android - Ionic cordova compile for android 在 minSdkVersion 上给出的错误小于声明的版本
- bash - 将字符串变量值插入到 ksh 中另一个字符串变量值的中间
- r - 在 R 中计算时间
- android - BottomAppBar 被推离屏幕
- node.js - 转到端点时收到有关 $pushAll 的错误,但没有在任何地方使用它