How to use structure binding with array in C++

1 Answer

0 votes
#include <iostream>
#include <array>

std::array<int, 3> getRGB() {
    return {189, 136, 255};
}

int main() {
    auto [r, g, b] = getRGB();
    
    std::cout <<  r << ' ' << g << ' ' << b;
}

 
 
 
/*
run:
 
189 136 255
 
*/

 



answered Dec 9, 2023 by avibootz

Related questions

1 answer 119 views
2 answers 142 views
1 answer 100 views
2 answers 160 views
1 answer 117 views
...