Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Org
//g++ 7.4.0 //Organization: Name Address and Date of Establishment //created by Rezaul Hoque on December 29,2020 //contact at jewelmrh@yahoo.com #include <iostream> #include <string> using namespace std; class Date{ friend istream& operator>>(istream&, Date&); friend ostream& operator<<(ostream&, const Date&); public: Date (int m=0, int d=0, int y=0) : month(m),day(d), year(y) {} void setDate(int m, int d, int y){ month = m; day= d; year=y;} private: int month, day, year; }; //overloaded insertion and extraction operators to get the desired date format istream& operator>>(istream& w, Date& d) { w>>d.month>>d.day>>d.year; return w; } ostream& operator<<(ostream& p,const Date& d) { static string monthName[13]= { " ", "January","February","March", "April","May","June","July","August","September","October","November","December"}; p<<monthName[d.month]<<' '<<d.day<<','<<d.year; return p; } //Class Org inherits all the public members of class Date class Org: public Date{ private: string name, address; Date dof; public: Org(){} Org (string n, string ad){ name =n; address = ad;} Org(Org& c){ name = c.name; address =c.address;} ~Org(){} virtual void setDOF(int m, int d, int y){ dof.setDate(m,d,y);} virtual Date getDOF() const { return dof;} virtual string getName() const { return name;} virtual string getAd() const {return address;} }; int main () { const int max=3; Org * Or; Or = new Org[max];//Or is a pointer to a block of 3 Org objects Or[0]={"AAA","123 nowhere"}; Or[1]={"BBB","321 nowhere"}; Or[2]={"CCC","222 nowhere"}; Or[0].setDOF(8,12,1820); Or[1].setDOF(6,10,1800); Or[2].setDOF(4,5,1850); cout<<"Name Address Established:\n"; for (int i=0; i<max; i++) { cout<<"\n"; cout<<Or[i].getName()<<"\t"; cout<<Or[i].getAd()<<"\t"; cout<<Or[i].getDOF()<<"\t"; cout <<endl; } delete [] Or; return 0; }
run
|
edit
|
history
|
help
0
string
Tower Of Hanoi
spiral traversal of a matrix
can be zero
uuuu
Valuing Fixed Income Investments
designated-inits
Treap for spoj : MEANARR (we can use policy based data structures instead)
doubly
CheckSymbolBalance