#include <iostream>
#include <string>
#include <vector>
struct UI
{
UI( const std::vector<std::string>& menuwords,
const std::string& either_header_or_footer, bool is_header ) ;
void display() const ;
// ...
std::vector<std::string> menuarray ;
std::string header_or_footer ;
bool head ;
bool foot ;
std::size_t place = 0 ;
};
UI::UI( const std::vector<std::string>& menuwords,
const std::string& either_header_or_footer, bool is_header )
: menuarray(menuwords), header_or_footer(either_header_or_footer)
{ head = is_header ; foot = !is_header ; }
void UI::display() const
{
for( std::size_t i = 0 ; i < menuarray.size() ; ++i )
{
if( i == place ) std::cout << '>' ;
else std::cout << ' ' ;
std::cout << menuarray[i] << '\n' ;
}
}
int main()
{
std::vector<std::string> menuwords { "zero", "one", "two", "three", "four" } ;
UI ui( menuwords, "this is a header", true ) ;
ui.display() ;
std::cout << "---------\n" ;
ui.place = 2 ;
ui.display() ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgoKc3RydWN0IFVJCnsKICAgIFVJKCBjb25zdCBzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4mIG1lbnV3b3JkcywKICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgZWl0aGVyX2hlYWRlcl9vcl9mb290ZXIsIGJvb2wgaXNfaGVhZGVyICkgOwoKICAgIHZvaWQgZGlzcGxheSgpIGNvbnN0IDsKCiAgICAvLyAuLi4KCiAgICBzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4gbWVudWFycmF5IDsKICAgIHN0ZDo6c3RyaW5nIGhlYWRlcl9vcl9mb290ZXIgOwogICAgYm9vbCBoZWFkIDsKICAgIGJvb2wgZm9vdCA7CgogICAgc3RkOjpzaXplX3QgcGxhY2UgPSAwIDsKfTsKClVJOjpVSSggY29uc3Qgc3RkOjp2ZWN0b3I8c3RkOjpzdHJpbmc+JiBtZW51d29yZHMsCiAgICAgICAgY29uc3Qgc3RkOjpzdHJpbmcmIGVpdGhlcl9oZWFkZXJ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