This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: compile error of type unmatch, plz help


Hy eric,
> but, there still are some compile error
> ---------------------------------------
> root@eric-laptop:/home/eric/BStrou/usingC++4/code/Chapter12# g++ -Wno-deprecated chapter.12.3.cpp  Simple_window.cpp  GUI.cpp Window.cpp -lfltk 
> Window.cpp:17: error: prototype for âGraph_lib::Window2::Window2(int, int, const String&)â does not match any in class âGraph_lib::Window2â
> Window.h:26: error: candidates are: Graph_lib::Window2::Window2(const Graph_lib::Window2&)
> Window.h:31: error:                 Graph_lib::Window2::Window2(Point, int, int, const std::string&)
> Window.h:29: error:                 Graph_lib::Window2::Window2(int, int, const std::string&)
> Window.cpp:25: error: prototype for âGraph_lib::Window2::Window2(Point, int, int, const String&)â does not match any in class âGraph_lib::Window2â
> Window.h:26: error: candidates are: Graph_lib::Window2::Window2(const Graph_lib::Window2&)
> Window.h:31: error:                 Graph_lib::Window2::Window2(Point, int, int, const std::string&)
> Window.h:29: error:                 Graph_lib::Window2::Window2(int, int, const std::string&)
> --------------------------------------------------------------------------------------
> here is my window.h and window.cpp
This are probably NOT the same files as the ones you passed to the compiler:
According to the error-message, the type "string" in Window.cpp:17 starts
with a capital letter -- in your Window.cpp that's not the case.
The same is true for Windows.cpp:25.

If those are really the correct files, I would suspect that in one of
the Header-files included in Window.cpp and NOT included in Window.h
(that is: Graph.h or GUI.h or files included into these two) you
redefine the type "string" (to be equivalent to a type "String") -- so
"string" in Window.cpp refers to a different type as "string" in
Window.h... 
If you remove the "using std::string;" in Window.h and replace all
occurences of "string" by "std::string", it should compile...

> /*****************************************************************/
> -----------------------------------Window.h---------------------
> #include <string>
> #include <vector>
> #include <FL/Fl.H>
> #include <FL/Fl_Window.H>
> #include "Point.h"
> 
> using std::string;
> namespace Graph_lib
> {
>     class Window2 : public Fl_Window { 
>     public:
>         Window2(int w, int h, const string & title);
>     };
> }
> /*****************************************************************/
> -----------------------------here is my Window.cpp-------------------
> #include <string>
> #include "Window.h"
> #include "Graph.h"
> #include "GUI.h"
> namespace Graph_lib {
> Window2::Window2(int ww, int hh, const string & title):Fl_Window(ww,hh,title.c_str()),w(ww),h(hh)
> {
>     init();
> }

Axel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]