Answers for "c++ 20 struct initialization"

C++
1

c++ 20 struct initialization

#include <iostream>
#include <filesystem>

struct hello_world {
    const char* hello;
    const char* world;
};

int main () 
{
    hello_world hw = {
        .hello = "hello, ",
        .world = "world!"
    };

    std::cout << hw.hello << hw.world << std::endl;
    return 0;
}
Posted by: Guest on August-17-2020

Browse Popular Code Answers by Language