1

LASReader.h

class LASReader
{

public:

LASReader();
~LASReader();

Point3 (LASReader::*GetPoint)();

private:

Point3 GetPointF0();
Point3 GetPointF1();
Point3 GetPointF2();
Point3 GetPointF3();
Point3 GetPointF4();
Point3 GetPointF5();
};

LASReader.cpp

switch (m_header.PointDataFormat)
{
case 0:
    m_formatSize = sizeof(LASPOINTF0);
    GetPoint = &LASReader::GetPointF0;
    break;
case 1:
    m_formatSize = sizeof(LASPOINTF1);
    GetPoint = &LASReader::GetPointF1;
    break;
case 2:
    m_formatSize = sizeof(LASPOINTF2);
    GetPoint = &LASReader::GetPointF2;
    break;
case 3:
    m_formatSize = sizeof(LASPOINTF3);
    GetPoint = &LASReader::GetPointF3;
    break;
case 4:
    m_formatSize = sizeof(LASPOINTF4);
    GetPoint = &LASReader::GetPointF4;
    break;
case 5:
    m_formatSize = sizeof(LASPOINTF5);
    GetPoint = &LASReader::GetPointF5;
    break;
default:
    break;  // Unknown Point Data Format
}

主文件

Point3 p = reader->GetPoint;

“错误 C2440:'正在初始化':无法从 'Point3 (__cdecl LASReader::* )(void)' 转换为 'Point3'”

当我使用手镯时

Point3 p = reader->GetPoint();

“错误 C2064:术语不计算为采用 0 个参数的函数”

我究竟做错了什么?

4

2 回答 2

2

你需要用(reader->*reader->GetPoint)()它来调用它。请参阅当它是类数据成员时如何调用指向成员函数的指针?

于 2013-07-23T01:38:50.257 回答
-1

函数指针语法如下

returnType (*yourFuncName)(argumentTypes);

所以你需要将你的成员重新定义为这样的东西

Point3 (*getPointFunc)(void);
于 2013-07-23T01:23:50.427 回答