// Code derived from Stroustrup's PPP2 book// § 8.6.2 Global initialization// -and beginning on p 293#include<iostream>usingnamespacestd;//------------------------------------------------------------------------------// as filename: f1.cppintx_1=1;inty_1=x_1+2;// y_1 becomes 3//------------------------------------------------------------------------------// as filename: f2.cppexterninty_1;inty_2=y_1+2;// y_2 becomes 2 or 5 (bad)//------------------------------------------------------------------------------structDate{Date(inty,intm,intd):y{y},m{m},d{d}{}inty;intm;intd;};namespacegood{constDatedefault_date{1970,1,1};// the default date is January 1 1970.}// namespace goodnamespacebetter{constDatedefault_date()// return the default Date{returnDate{1970,1,1};}}// namespace betternamespacebest{constDate&default_date(){staticconstDatedd{1970,1,1};// initialize dd first time we get herereturndd;}}// namespace bestintmain(){Dated1=good::default_date;Dated2=better::default_date();Dated3=best::default_date();cout<<d1.y<<d2.y<<d3.y<<'\n';}