C++:为什么在包含标头时收到"未在此范围内声明"错误?

C++: Why do I get a ´not declared in this scope´ error when I included the header?

本文关键字:范围内 声明 错误 为什么 包含标 C++      更新时间:2023-10-16

在我的代码中,我使用了一个类CameraHeapMemory,它由第491行标题定义,如下所示:

 class CameraHeapMemory : public RefBase {
    public:
       CameraHeapMemory(int fd, size_t buf_size, uint_t num_buffers = 1) :
                         mBufSize(buf_size),
                         mNumBufs(num_buffers)

我在源代码中使用include:

 #include "CameraHardwareInterface.h"

我的代码然后使用如下行:

 sp<CameraHeapMemory> mem(static_cast<CameraHeapMemory *>(data->handle));

但是当我编译时,我得到:

  error: 'CameraHeapMemory' was not declared in this scope"

有人知道为什么吗?

'CameraHeapMemory'似乎是在'CameraHardwareInterface'中定义的私有类。在"CameraHardwareInterface"之外无法访问。