Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
DayTempEnum
//g++ 7.4.0 ////////////////////////////////////////////////////////////////////////////// DayTempEnum: example of unscoped enumeration and scoped enumeration // //this code is created by Rezaul Hoque on May 18,2022; //contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; ////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> enum Day {Sun,Sat,Mon,Tue,Wed,Thu,Fri}; enum class Rain : char {No='o', Cloud='c', Little='l', NonStop='r', Heavy='h'}; std::ostream& operator<<(std::ostream& outs, Rain r) { return outs << static_cast<char>(r); } struct DayTemp{ public: float temp; int day; Rain weather; struct { char Region[80]; char city[80]; }location; }; int main() { int n=3; struct DayTemp p[n]; strcpy(p[0].location.Region,"North"); strcpy(p[0].location.city,"NoVille"); p[0].day=Day::Mon; p[0].temp=10.5; p[0].weather=Rain::NonStop; strcpy(p[1].location.Region,"East"); strcpy(p[1].location.city,"UtoVille"); p[1].day=Day::Fri; p[1].temp=30; p[1].weather=Rain::No; strcpy(p[2].location.Region,"West"); strcpy(p[2].location.city,"Zeroland"); p[2].day=Day::Thu; p[2].temp=20; p[2].weather=Rain::Heavy; std::cout<<"Region City Day Temp Weather\n"; for(int h=0;h<n;h++){ std::cout<<p[h].location.Region<<" "; std::cout<<p[h].location.city<<" "; std::cout<<p[h].day<<" "; std::cout<<p[h].temp<<" "; std::cout<<p[h].weather<<"\n"; } return 0; }
run
|
edit
|
history
|
help
0
Comp Conexe
ConversionOperator
always_late
LRU - DLL
Hello World
test111
Generating π from 1,000 random numbers
pac update
g++ -Wall *.cpp -o aco; ./aco.
virtual function role