Unknown Override specifier. Noob question

Im quite confuse on headers

Say for example I have this base class

1
2
3
4
5
class BaseClass
{
public:
	virtual void Load(std::string msg);
};


And a derive class

1
2
3
4
5
6
#include "header.h"
class DeriveClass : public BaseClass
{
public:
	DeriveClass();
};



And a class that will call the derive

1
2
3
4
5
6
7
#include "Header.h"

class Game
{
private:
	static DeriveClass c1;
};


I always got this Unknow Overried specifier.

But I already define if on my baseclass.cpp

1
2
3
4
void BaseClass::Load(std::string msg) {

	//some stuff here
}


also I have a pragma once on my

header.h
1
2
3
4
#pragma once
#include "BaseClass.h"
#include "DeriveClass.h"
#include "Game.h" 


So it means any of that header will only be declared if others have not declared it yet.

But still I got that error


However if I never include a header.h on Derive class and just put
#include "BaseClass.h"

It just works fine. How did that happen? It shows an error when using the header file which contains all the header of all classes and yet works fine when using baseclass.h?

Last edited on
There is nothing wrong with the code you have provided: https://ideone.com/aFSpqx

Please copy and paste the exact error message and indicate which line it is referring to.
Hello.

I believe it will work because theyre all on a single file.

But that is all i have in my code.

Only difference is that I declared all classes on separate file and using a single header file to declare the headers of each classes.

then use that single header file
#include just copies and pastes - I did the same thing.

Please copy and paste the exact error message and indicate which line it is referring to.
Hello This is the project i have. its just simple one

https://www.dropbox.com/s/4qeamzefbpbcji7/ConsoleApplication1.7z?dl=0

This is the error I keep getting

1
2
3
Severity	Code	Description	Project	File	Line
Error	C3646	'c1': unknown override specifier	ConsoleApplication1	
Error	C4430	missing type specifier - int assumed. Note: C++ does not support default-int	ConsoleApplication1	

Last edited on
The issue is that you have circular dependencies with your headers.

Game.h includes Header.h, but Header.h includes Game.h - it would go on for infinity if it had not been for that error message.

Please read throroughly:
http://www.cplusplus.com/articles/Gw6AC542/
I see. so thats why.

its weird though, I thought that pragma once will catch that issue.

thanks for the article. It works when I remove the Game.h from the header.h.
Last edited on
Topic archived. No new replies allowed.