Answer the question
In order to leave comments, you need to log in
Why is the class definition not visible?
Hello. I am new to C++. Programming in VisualStudio2008 There was a problem when including header files. I have file MyClasses.h:
#ifndef MYCLASSES_H
#define MYCLASSES_H
namespace my {
// Some template classes
...
MyClass {declaration} // My class (not template) contains static methods only
// Other classes declaration
};
#endif
namespace my {
// implementation of MyClass and other classes
}
#include "MyClasses.h"
class MyClass;
#include "MyClasses.h"
I geterror C2653: 'MyClass' : is not a class or namespace name
on the lineMyClass::StaticMethod(); // или так my::MyClass::StaticMethod();
#include "MyClasses.h";
class MyClass;
or so#include "MyClasses.h";
namespace my { class MyClass; }
then I get an error error C2027: use of undefined type 'my::MyClass'
on the linemy::MyClass::StaticMethod();
Answer the question
In order to leave comments, you need to log in
See if you are using Precompiled headers.
If so, is there a first line entry in each .cpp
Good article on Habré
What is the first error the compiler reports? And it would be nice to show how you define the MyClass class, there is a suspicion that you just have a mistake there.
Also, this is not particularly relevant, but it looks like you have a mistake here:
#ifndef MYSECLASSES_H
#define MYCLASSES_H
As already written above, show your class declaration file and preferably a complete list of compilation errors associated with this class.
strange design, what did you want to tell her?
#include "MyClasses.h"
class MyClass;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question