help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: structs and STL stack


From: red floyd
Subject: Re: structs and STL stack
Date: Fri, 17 Mar 2006 17:56:17 GMT
User-agent: Thunderbird 1.5 (Windows/20051201)

Christian Christmann wrote:
Hi,

I'd like to store structs on an STL stack.

Here is a piece of my code:

        #inclue <stack>   
        ...

        struct storeInfo {
          int a;
        } structInfo;

        stack< storeInfo > itStack;
        ...


When compiling with gcc 3.3.2, I get the error
message:
error: template-argument `areg_action(burm_state*,
   std::basic_string<char, std::char_traits<char>, std::allocator<char>
   >)::storeInfo' uses local type `areg_action(burm_state*,
   std::basic_string<char, std::char_traits<char>, std::allocator<char>
   >)::storeInfo'
error: template argument 2 is invalid
error: ISO C++ forbids declaration of `itStack' with no type

What is wrong?
Thank you.


Two things.

1. you generally want to divorce type declarations and variable declarations.

2. It looks like you might be declaring storeInfo as local to a function. You can't use a local type declaration as a template param.

try:

struct storeInfo {
 // ...
};

storeInfo structInfo;

void f()
{
stack<storeInfo> itStack;

}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]