Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #struct #initialization
ADD COMMENT
Topic
Name
6+8 =