|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Here is the error, and the program run no problem in VC++;
Compiler: Default compiler Building Makefile: "H:\CS2332\Summer\STL001\Makefile.win" Executing make... make.exe -f "H:\CS2332\Summer\STL001\Makefile.win" all g++.exe -c R03_stackDriver.cpp -o R03_stackDriver.o -I"C:/Dev-Cpp/lib/ gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/ 3.4.2" -I"C:/Dev-Cpp/include" In file included from R03_stackDriver.cpp:2: R03_stack.h:105: error: declaration of `class T' R03_stack.h:19: error: shadows template parm `class T' In file included from R03_stack.h:115, from R03_stackDriver.cpp:2: R03_stack.cpp.h: In member function `bool Stack<T>::contains(const T&) const': R03_stack.cpp.h:116: error: expected `;' before "p" R03_stack.cpp.h:117: error: `p' undeclared (first use this function) R03_stack.cpp.h:117: error: (Each undeclared identifier is reported only once for each function it appears in.) R03_stack.cpp.h: In member function `unsigned int Stack<T>::count(const T&) const': R03_stack.cpp.h:131: error: expected `;' before "p" R03_stack.cpp.h:132: error: `p' undeclared (first use this function) R03_stack.cpp.h: In member function `unsigned int Stack<T>::count(const T&) const [with T = int]': R03_stackDriver.cpp:75: instantiated from here R03_stack.cpp.h:131: error: dependent-name ` std::vector<T,std::allocator<_CharT> >::const_iterator' is parsed as a non-type, but instantiation yields a type R03_stack.cpp.h:131: note: say `typename std::vector<T,std::allocator<_CharT> >::const_iterator' if a type is meant R03_stack.cpp.h: In member function `bool Stack<T>::contains(const T&) const [with T = int]': R03_stackDriver.cpp:83: instantiated from here R03_stack.cpp.h:116: error: dependent-name ` std::vector<T,std::allocator<_CharT> >::const_iterator' is parsed as a non-type, but instantiation yields a type R03_stack.cpp.h:116: note: say `typename std::vector<T,std::allocator<_CharT> >::const_iterator' if a type is meant make.exe: *** [R03_stackDriver.o] Error 1 Execution terminated Some of the code(the Dev C++ says there are errors), /** * @brief display the whole stack */ template <class T> friend ostream& operator << (ostream& outStream, const Stack<T>& out); How can I fix the problems? Thanks! |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Jul 2, 11:06 am, SamuelXiao <foolsmart2...@gmail.com> wrote:
> Here is the error, and the program run no problem in VC++; > Compiler: Default compiler > Building Makefile: "H:\CS2332\Summer\STL001\Makefile.win" > Executing make... > make.exe -f "H:\CS2332\Summer\STL001\Makefile.win" all > g++.exe -c R03_stackDriver.cpp -o R03_stackDriver.o -I"C:/Dev-Cpp/lib/ > gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" > -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/ > 3.4.2" -I"C:/Dev-Cpp/include" > > In file included from R03_stackDriver.cpp:2: > R03_stack.h:105: error: declaration of `class T' > > R03_stack.h:19: error: shadows template parm `class T' > In file included from R03_stack.h:115, > from R03_stackDriver.cpp:2: > R03_stack.cpp.h: In member function `bool Stack<T>::contains(const T&) > const': > R03_stack.cpp.h:116: error: expected `;' before "p" > R03_stack.cpp.h:117: error: `p' undeclared (first use this function) > R03_stack.cpp.h:117: error: (Each undeclared identifier is reported > only once for each function it appears in.) > R03_stack.cpp.h: In member function `unsigned int > Stack<T>::count(const T&) const': > > R03_stack.cpp.h:131: error: expected `;' before "p" > R03_stack.cpp.h:132: error: `p' undeclared (first use this function) > R03_stack.cpp.h: In member function `unsigned int > Stack<T>::count(const T&) const [with T = int]': > R03_stackDriver.cpp:75: instantiated from here > R03_stack.cpp.h:131: error: dependent-name ` > std::vector<T,std::allocator<_CharT> >::const_iterator' is parsed as a > non-type, but instantiation yields a type > > R03_stack.cpp.h:131: note: say `typename > std::vector<T,std::allocator<_CharT> >::const_iterator' if a type is > meant > R03_stack.cpp.h: In member function `bool Stack<T>::contains(const T&) > const [with T = int]': > R03_stackDriver.cpp:83: instantiated from here > R03_stack.cpp.h:116: error: dependent-name ` > std::vector<T,std::allocator<_CharT> >::const_iterator' is parsed as a > non-type, but instantiation yields a type > R03_stack.cpp.h:116: note: say `typename > std::vector<T,std::allocator<_CharT> >::const_iterator' if a type is > meant > > make.exe: *** [R03_stackDriver.o] Error 1 > > Execution terminated > > Some of the code(the Dev C++ says there are errors), > > /** > * @brief display the whole stack > */ > template <class T> > friend ostream& operator << (ostream& outStream, const Stack<T>& > out); > > How can I fix the problems? Thanks! Hello, I believe you should provide minimal code that reproduces the error. Regards. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Wed, 02 Jul 2008 02:06:32 -0700, SamuelXiao wrote:
> Here is the error, [...] Please read: http://www.parashift.com/c++-faq-lit...t.html#faq-5.8 Thanks, -- Lionel B |
|
![]() |
| Outils de la discussion | |
|
|