I have this function:
array<int, 2> foo() { array<int, 2> = nums; return nums;}
This returns the error "array does not name a type". Why is this?
You need to include array. And as was pointed out, you have the incorrect syntax for the array declaration.
Try this:
#include <array>
std::array<int, 2> foo() {
std::array<int, 2> nums;
return nums;
}
int main() {
// use your function here
}
return {}; in the function.main empty. Or just delete the program. Or turn off your computer... ;)
std::and#include <array>?#include <array>?array<int, 2> = nums;is also incorrect, you probably wantarray<int, 2> nums = {42, 42};