Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
TupleTel
//g++ 7.4.0 ////////////////////////////////////////////////////////////////////////////// //TupleTel: example of tuple as class attribute //this code is created by Rezaul Hoque on August 07,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> #include <tuple> using namespace std; //stream manipulator std::ostream& l(std::ostream& os) { return (os<<"\n"); } namespace Pat { void fill(char c) { std::cout.width(40); std::cout.fill(c); std::cout<<l; } void left(int n,char c){ std::cout.setf(std::ios::left); std::cout.fill(c); std::cout.width(n); } void right(int n,char c){ std::cout.setf(std::ios::right); std::cout.fill(c); std::cout.width(n); } } namespace Tel{ class Tel{ std::string name; bool update; tuple<std::string,int> l; public: Tel(){} Tel(std::string n,bool y,tuple<std::string,int> m){l=m;name=n;update=y;} Tel(Tel& c){l=c.l;name=c.name;update=c.update;} ~Tel(){} std::string getName(){return name;} bool getUpd(){return update;} tuple<std::string,int> getL(){ return l;} }; } int main() { std::string s; int t; Tel::Tel ad("X",true,make_tuple("CBA",100)); tie(s,t)=ad.getL(); Pat::fill('@'); Pat::left(18,' '); std::cout<<"Name"<<"ContName"<<" Number"<<l; Pat::left(18,' '); std::cout<<ad.getName()<<" "<<get<0>(ad.getL())<<" "<<t<<l; Pat::fill('@'); return 0; }
run
|
edit
|
history
|
help
0
Cuantos dedos
Queue with Limited Size of Arrays
st_match
SIP_parser_with_std_regex_need_help_to_improve_it.cc
Sorting Array
rotation
27
Problema Siruri
2015(M2)Mod.
bind function