Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
#include <string>
using namespace std;
//Class tourist
class tourist
{string name,country;//opening class
int birthday;
char sex;
public:
tourist(){name=country="xxx";birthday=0;sex='m';}//default constructor
tourist (string n,string c,int b,char s)//explicit constructor
{name=n,country=c,birthday=b,sex=s;}
tourist( const tourist& tr): //copy constructor
name( tr.name ),country( tr.country),sex( tr.sex),birthday(tr.birthday)//end of constructor
{}
~tourist()//destructor
{}
//Set functions Name
void setName(string n)
{
name = n;
}
//Set functions Country
void setCountry(string c)
{
country = c;
}
//Set functions Birthday
void setBirthday(int b)
{
birthday = b;
}
//Set functions Sex
void setSex(char s)
{
sex = s;
}
//Get functions Name
string getName()
{
return name;
}
//Get functions Country
string getCountry()
{
return country;
}
//Get functions Birthday
int getBirthday()
{
return birthday;
}
//Get functions Sex
char getSex()
{
return sex;
}
//Function Age
int age(){
return 2015-birthday;
}
bool operator<(tourist t){
return (this->age()<t.age()) ? true: false;
}// like if else
//Print function
void print(){
cout<<"Name:"<<" "<<name<<endl;
cout<<"Country:"<<" "<<country<<endl;
cout<<"Birthday:"<<" "<<birthday<<endl;
cout<<"Sex:"<<" "<<sex<<endl;
}
};//closing class
//Class hotel
class hotel:public tourist //inherit Tourist class
{string nameH;
int days, cost;
public:
hotel ():tourist() {nameH="xxx";days=cost=0;}; //default constructor
hotel (string h,int d,int co){nameH=h,days=d,cost=co;}//explicit constuctor
hotel (string h ,int d ,int co ,string n,string c,int b,char s):tourist ( n, c, b, s){
nameH=h,days=d,cost=co;
};//copy constuctor
int bill(){return days*cost;}
bool operator<(hotel b){
return (this->bill()<b.bill()) ? true: false;
}// like if else
void print(){
tourist::print();
cout<<"Name of the hotel:"<<" "<<nameH<<endl;
cout<<"Days of rest:"<<" "<<days<<endl;
cout<<"Cost per day:"<<" "<<cost<<endl;
}
};//closing class
int main()
{
tourist tm1,tm2,tm3,tm4;
hotel h1("Hilton",5,100,"Rashad","Azerbaijan",1993,'m');
h1.print();
hotel people[3];
system("pause");
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team