Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 834
Josh Ayres Avatar asked Feb 08 '23 15:02

Josh Ayres


2 Answers

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.

like image 139
Mateusz Grzejek Avatar answered Feb 11 '23 05:02

Mateusz Grzejek


I got this in my C++ code for unreal engine. It was because I forgot the semi-colon at the end of the class declaration in my header (.h) file.

class MyClass{
private: //Stuff here
public:  //Stuff here
}; //<--------DONT FORGET THE SEMICOLON
like image 37
twitchdotcom slash KANJICODER Avatar answered Feb 11 '23 03:02

twitchdotcom slash KANJICODER