Language
C++
Compiler
gcc 9.2.0
Options
Warnings
Boost 1.72.0
C++2a(GNU)
no pedantic
#include <iostream>
#include <string>
struct Window
{
inline static unsigned int default_width = 1028;
inline static unsigned int default_height = 768;
unsigned int _width { default_width };
unsigned int _height { default_height };
unsigned int _flags : 4 { 0 };
std::string _title { "Default Window" };
Window() { }
Window(std::string title) : _title(std::move(title)) { }
friend std::ostream& operator<<(std::ostream& os, const Window& w) {
os << w._title << ": " << w._width << "x" << w._height;
return os;
}
};
int main()
{
Window w("Super Window");
std::cout << w << '\n';
Window::default_width = 1920;
Window w2("Almost HD Window");
std::cout << w2 << '\n';
}
$ g++ prog.cc -Wall -Wextra -I/opt/wandbox/boost-1.72.0/gcc-9.2.0/include -std=gnu++2a
Super Window: 1028x768
Almost HD Window: 1920x768
Exit Code:
0