Dev C++ compile problem

S

SamuelXiao

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!
 
A

alasham.said

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top