简体   繁体   中英

STL: container of container

I'm noob but as i know it doesnt matter what's data type container contains. So here is what i'm trying to do:

std::deque<list<U32> >     ReqLis;

And result of it is next:

error: ISO C++ forbids declaration of 'deque' with no type
error: invalid use of '::'
expected ';' before '<' token

But when instead of it i try to do this:

std::list<list<U32> >      ReqList;

That's ok..................

Question is am i such great noob or is it compiler fail? I'm using gcc/g++

Could you list all the code? The usage of namespaces in your code a bit loose.

The deque in a separate header cpp reference

#include <deque>

There is no standard type called U32, but if you #include (stdint.h for C) you can use std::uint32_t1, a 32 bit unsigned integer, which is (I assume) what you want.

first you should include this header file for user u32

   #include <cstdint>

   std::deque<std::list<std::uint32_t>> ReqList;

Add following :

#include <list>
#include<deque>
#include<stdint.h>
     std::deque<uint32_t> ReqList;



  #include<deque> is for deque data type
  #include<list>  is for list data type
  #include<stdint.h> is for uint32_t (Integer type with a width of exactly 8, 16, 32, or  
                     64 bits.For signed types, negative values are represented using 2's 
                     complement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM