Compiler Error Does Not Name A Type
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings does not name a type c++ error and policies of this site About Us Learn more about Stack Overflow
C++ Does Not Name A Type Class
the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation does not name a type c++ struct Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it
Variable Does Not Name A Type C++
only takes a minute: Sign up Class name does not name a type in C++ up vote 7 down vote favorite 2 I just started programming in C++, and I've tried to create 2 classes where one will contain the other. File A.h: #ifndef _A_h #define _A_h class A{ public: A(int id); private: int _id; B _b; // HERE I does not name a type qt GET A COMPILATION ERROR: B does not name a type }; #endif File A.cpp: #include "A.h" #include "B.h" #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies
C++ Does Not Name A Type Typedef
of this site About Us Learn more about Stack Overflow the company
Has Incomplete Type C++
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges c++ does not name a type namespace Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: http://stackoverflow.com/questions/3608305/class-name-does-not-name-a-type-in-c Sign up Error: '…' does not name a type up vote 5 down vote favorite 1 I had a working project. After rearranging some code, I tried to recompile my project and then weird things started happening. Have a look at this excerpt from the compiler's output. I'm compiling from Eclipse on Windows using MinGW G++. **** Build of configuration Debug for http://stackoverflow.com/questions/3961103/error-does-not-name-a-type project Pract2 **** **** Internal Builder is used for build **** g++ -O0 -g3 -Wall -c -fmessage-length=0 -omove.o ..\move.cpp In file included from ..\/game.h:11:0, from ..\/piece.h:10, from ..\/move.h:10, from ..\move.cpp:7: ..\/board.h:18:2: error: 'Piece' does not name a type board.h, line 18: Piece* GetPieceAt(int row, int col) const; Usually when that happens, I just have to add some inclusions I've forgotten to do. But I have in fact included piece.h at the top of board.h. My second thought was that the compiler must have generated an error somewhere in the Piece class that would cause the compiler ignore the existence of the class, which in turn would cause more errors. In that case I'd look at the first compiler error, which I expected would be something about an error in piece.cpp or piece.h. But the first error isn't about Piece at all, so I looked if Eclipse had marked any errors in piece.cpp or piece.h. Nope, not a red line in sight. I only saw a few of these unexplained yellow markers. One last thing that I checked was that every header file contained inclusion g
inherit from it using public BaseClass. In each derived class's header, I #include baseclass.h . In http://www.cplusplus.com/forum/general/100728/ a different header file, I #include all five of these classes (but not the base class), and declare a pointer to one of each. The problem is, http://www.qtcentre.org/threads/38296-Class-does-not-name-a-type-error I only get the 'class' does not name a type error for one of these classes. I'm positive I spelled it right, so that's not the problem. I does not also tried forward declaration (which gave me more errors). What could the problem be? Last edited on Apr 30, 2013 at 6:59am UTC Apr 30, 2013 at 7:13am UTC MiiNiPaa (8886) Do you have header guards in your headers? Apr 30, 2013 at 7:52am UTC Catfish4 (666) If you don't, and don't know what they are, does not name just put #pragma once at the beginning of all of your header files. Apr 30, 2013 at 8:21am UTC keskiverto (5717) Just in case the compiler does not support that pragma: http://en.wikipedia.org/wiki/Include_guard Apr 30, 2013 at 10:08am UTC trojansdestroy (121) I do have header guards. I've also tried declaring the pointer this way: BaseClass* instance; thinking that polymorphism compiles. Then g++ decides that the inheriting class is an int*, which it is most definitely not. Last edited on Apr 30, 2013 at 10:12am UTC Apr 30, 2013 at 10:15am UTC MiiNiPaa (8886) Cna you please show the header for problem file. Apr 30, 2013 at 10:39am UTC trojansdestroy (121) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// baseclass.h #ifndef BASECLASS_H #define BASECLASS_H #include // some Qt headers class BaseClass: public /* Qt object */ { public: BaseClass(int x, int y); // methods protected: // members }; #endif 1
2
3
4
5
6
7
8
9
10
11
12
13
// class.h #ifndef CLASS_H #define CLASS_H #include "baseclass.h" class Class: public BaseClass { public: Class(int x, int y); }; #endif 1
2
3<
error If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Welcome to Qt Centre. Qt Centre is a community site devoted to programming in C++ using the Qt framework. Over 90 percent of questions asked here gets answered. If you are looking for information about Qt related issue — register and post your question. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. + Reply to Thread Results 1 to 10 of 10 Thread: 'Class' does not name a type error Thread Tools Show Printable Version Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 31st January 2011,16:43 #1 naturalpsychic View Profile View Forum Posts View Blog Entries View Articles Novice Join Date Jan 2011 Location Australia Posts 44 Qt products Platforms 'Class' does not name a type error hi, its probably some silly mistake in c++ but my code is not working, it gives me error. here is code _time.h Qt Code: Switch view #ifndef _TIME_H#define _TIME_H#include