0

I'm fairly new at C++, but I'm trying to read in a .las file. I'm sort of following this youtube video, but I'm still having some issues reading in the file.

I'm getting several errors:

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|

Code:

#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;
      }
    }
}

I'm not sure why it is complaining about the prototype I think I have everything right in the header. Also all the variables in the header struct come from this link.

Any help would be greatly appreciated. Thanks

p0ps1c1e
  • 176
  • 2
  • 2
  • 14
  • You're missing the return type from the `PointCloud::read` definition. And you have unmatched braces; I think there is a closing brace (`}`) too much at the bottom. – ravnsgaard Nov 21 '18 at 22:55
  • @ravnsgaard, do I still need to specify a return type even though it's void? – p0ps1c1e Nov 22 '18 at 02:12
  • Yes, you do. You're running into an ancient rule in the system (inherited from C) that makes anything not explicitly declared an `int`. Your compiler should have more to say about this... What compiler are you using? What version? – ravnsgaard Nov 22 '18 at 12:36
  • I'm running GCC im not sure the version as I'm on Windows and its kind of a pain to check – p0ps1c1e Nov 22 '18 at 18:15
  • So what should the return type be in this case? Sorry I'm a C++ newbie – p0ps1c1e Nov 22 '18 at 18:27
  • 1
    You're not returning anything. So, the return type should be `void`. It already is in your declaration, but there's no return type on your definition. This mismatch is what the compiler's complaining about. – ravnsgaard Nov 22 '18 at 19:07

0 Answers0