c++ - How to access a vector array? -


std::vector<int> example[1024]; 

how can access 1024 "examples" , vector elements?

when try example[0] same example.at(0) , access the first element in vector...

i want same variables: int variable[1024]; ... instead of integer there vector...

it not clear want accomplish, std::vector works pretty classic c++ array.

and elements go 1 after in memory, can example

  std::vector<int> test(1024);   test[0] = 1;   test[1] = 4;   test[2] = 8;    int* first = &test[0];   std::cout << "first " << *first << std::endl;   int* second = first + 1;   std::cout << "second " << *second << std::endl; 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -