How do I use <uint64_t> in an array

449 Views Asked by At

i'm pretty new to C++ and am trying to make an array in which every element is of a specific bit-size. I've tried doing this: Sequence<uint64_t>; In which Sequence would be the array name and every element would have a size of 64 bits. However get the following error: "error: ‘Sequence’ does not name a type" Thanks in advance!

1

There are 1 best solutions below

2
wohlstad On

std::vector and std::array are the recomended array containers in C++.

You can use std::vector if you need a dynamic size array, e.g.:

#include <cstdint>
#include <vector>
std::vector<uint64_t> v;

And use std::array for a fixed size array, e.g.:

#include <cstdint>
#include <array>
std::array<uint64_t, 10> a;

You can see in the links above how to use these containers.