Josh Ayres Josh Ayres - 1 month ago 12
C++ Question

Error 1 error C2143: syntax error : missing ';' before '<class-head>'

Hello I am writing a IOManager, but I get this error:

Error 1 error C2143: syntax error : missing ';' before '<class-head>'


My code is this:

#pragma once
#include <vector>

class IOManager{
public:
static bool readFileToBuffer(std::string filePath, std::vector<unsigned char>& buffer);
};


I don't know what I did wrong!

Answer

You use std::string, but did not include <string> header. Add this line to the top:

#include <string>

So you will get:

#pragma once

#include <string>
#include <vector>

class IOManager{
public:
    static bool readFileToBuffer(std::string filePath, std::vector<unsigned char>& buffer);
};

It should work.

Comments