0

我是 C++ 的新手,但我正在尝试读取 .las 文件。我有点关注这个 youtube 视频,但我在读取文件时仍然遇到一些问题。

我收到几个错误:

error: prototype for 'int PointCloud::read(const string&)' does not match any in class 'PointCloud'|
candidate is: void PointCloud::read(const string&)|
expected declaration before '}' token|
error: prototype for 'int PointCloud::read(const string&)' does not match any    in class 'PointCloud'|
error: candidate is: void PointCloud::read(const string&)|
error: expected declaration before '}' token|

代码:

#ifndef POINTCLOUD_H
#define POINTCLOUD_H
#include <stdint.h>
#include <string>

class PointCloud
{

public:
    PointCloud(const std::string &path);

private:
struct Header
        {
            char magic[4];
            uint16_t fileSourceID;
            uint16_t globalEncoding;
            uint32_t guidData1;
            uint16_t guidData2;
            uint16_t guidData3;
            uint8_t guidData4;
            uint8_t versionMaj, versionMin;
            char systemIdentifier[32];
            char genSoftware[32];
            uint16_t creationDay, creationYear;
            uint16_t headerSize;
            uint32_t pointDataOffset;
            uint32_t numVarLenRecords;
            char pointDataFormat;
            uint16_t pointDataRecordLen;
            uint32_t pointRecordNum;
            uint32_t pointReturnNum[5];
            double  scaleX, scaleY, scaleZ;
            double offX, offY, offZ;
            double maxX, maxY, maxZ;
            double minX, minY, minZ;
        };
    void read(const std::string &path);

};

#endif //POINTCLOUD_H

#include "PointCloud.h"
#include <iostream>
#include <stdexcept>
#include <fstream>>

using namespace std;
PointCloud::read(const string &path)
  {
    ifstream inf(path, ios::binary);
    if(inf.is_open())
      {
        Header header;
        inf.read((char *))&header, sizeof(header));
        cout << header.versionMaj << "," << header.versionMin << endl;
      }
        else
      {
        cout << "Error: No file found" << endl;
      }
    }
}

我不确定为什么它抱怨原型我认为我在标题中拥有一切。标头结构中的所有变量也来自此链接

任何帮助将不胜感激。谢谢

4

0 回答 0