Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
NameTempSpecial2
//g++ 7.4.0 //NameTempSpecial2 //this code is created by Rezaul Hoque on May 15,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 <string> enum Day {Sat,Sun,Mon,Tue,Wed,Thu,Fri}; namespace intro{ template<class X> class Deco{ public: template<class Y> void f1(Y){std::cout<<"-------";} void f2(){std::cout<<"This is a demo";} }; template <> class Deco<std::string>;//forward declare spec } template <> class intro::Deco<std::string>{ public: template<class Y> void f1(Y n) { for(int m=0;m<n;m++){ std::cout<<"<"; } std::cout<<"\n"; for(int m=0;m<n;m++){ std::cout<<">";} std::cout<<"\n"; } void f2(){std::cout<<"Namespace & Template Specialization Example \n";} }; template<class X,class Y,class Z> class DayTemp{ X w; Y temp; Z precip; public: DayTemp (){} DayTemp(X a,Y c,Z e){ temp=c; w=a; precip=e;} DayTemp(DayTemp& y){ temp=y.temp;w=y.w;precip=y.precip;} ~DayTemp (){} Y getTemp(){ return temp;} X getDay(){return w;} Z getPreci(){return precip;} }; int main() { const int sz=7; intro::Deco<std::string> a; a.f1(35); a.f2(); a.f1(35); DayTemp<Day,float,int> * p; p=new DayTemp<Day,float,int>[sz]; p[0]={Thu,20.4,0}; p[1]={Wed,30,10}; p[2]={Mon,35,20}; p[3]={Tue,50,0}; p[4]={Sun,45,28}; p[5]={Sat,36,33}; p[6]={Fri,29,23}; std::cout<<" Day Temp Rain\n"; for(int r=0;r<sz;r++){ std::cout<<p[r].getDay()<<"\t"; std::cout<<p[r].getTemp()<<"\t"; std::cout<<p[r].getPreci()<<"\n"; } delete [] p; return 0; }
run
|
edit
|
history
|
help
0
Bin Tree build
Test Euler Graph
shell sort
PyramidTransitionMatrix_recursive
Member function detection
Test 20(2020)
Rectangle overlap
Programa 3(Creo que ya esta)
pointconcat
Const Return Test