This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
gcc (g++4.4.3) have no right to modify the name of my varialbe
- From: "eric lin" <fsshl at luxmail dot com>
- To: <gcc at gcc dot gnu dot org>, <gcc-help at gcc dot gnu dot org>
- Date: Thu, 4 Nov 2010 12:35:52 -0700
- Subject: gcc (g++4.4.3) have no right to modify the name of my varialbe
- Reply-to: <fsshl at luxmail dot com>
dear alex:
thanks your email, but
(1) your suggestion is not work, it still get same error
(2) g++(4.4.3) have no right to modify the name of my variable, it is "string" that I use(or Bjarne Stroustrup use)
not "String" that gcc/g++4.4.3 show on the compiler error
(3) if I put std::string replace string on Window.cpp file, g++ will complaint
root@eric-laptop:/home/eric/BStrou/usingC++4/code/Chapter12# g++ -Wno-deprecated chapter.12.3.cpp Simple_window.cpp GUI.cpp Window.cpp Graph.cpp -lfltk
Window.cpp:17: error: expected unqualified-id before â&â token
Window.cpp:17: error: expected â)â before â&â token
Window.cpp:17: error: expected initializer before â&â token
Window.cpp:25: error: expected unqualified-id before â&â token
Window.cpp:25: error: expected â)â before â&â token
Window.cpp:25: error: expected initializer before â&â token
---------------------------------------------------------------
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
_____________________________________________________________
Luxmail.com is spam free. However, we do not throw your important emails into spam box like other defective email systems.