Skip to main content

CONSTRUCTOR OVERLOADING


#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
class theatre
{
int cost,seat,t_cost; char *ac;
public:
  theatre()
  { 
cost=10;
cout<<"\n Enter the no.of seats required:";
            cin>>seat;
            t_cost=cost*seat;
            cout<<"\nTicket cost of " <<seat<< " seats is Rs."<<t_cost;
  }
theatre(int a)
  {
    seat=a;
    cost=100;
t_cost=cost*seat;
    cout<<"\n Ticket cost of " <<seat<< " seats is Rs."<<t_cost;
  }
   theatre(int a,char *b)
  {
     seat=a;
ac=b;
     cost=100;
     cost=cost+50;
     t_cost=seat*cost;
     cout<<"\n"<<ac;
     cout<<"\n Ticket cost of "<<seat<<" seats is Rs."<<t_cost;
  }
  };
void main()
{
int n,ch;
clrscr();
cout<<"\t\t\t\tMAGNA THEATRE\n";
cout<<"\t\t\t\t*************";
cout<<"\n 1.Low Class   - Rs.10/seat";cout<<"\n 2.Middle Class- Rs.100/seat";
cout<<"\n 3.High Class  - Rs.150/seat";
do
{
cout<<"\n\n Enter the class you prefer:";
cin>>ch;
switch(ch)
{
  case 1:
       cout<<"\n\t LOW CLASS";
    theatre t; break;
  case 2:
      cout<<"\n\n\t MIDDLE CLASS";
         cout<<"\n Enter the no.of seats required:";
       cin>>n;
      theatre t1(n);break;
case 3:
      cout<<"\n\n\t HIGH CLASS";
        cout<<"\n Enter the no.of seats required:";
       cin>>n;
       theatre t2(n,"High class A\C");break;
          default:
  exit(0);
}
}while(ch<=3);
getch();

Comments

Popular posts from this blog

CALCULATOR USING CONTROL ARRAY

Public curval As Double Public preval As Double Public choice As String Public result As Double Private Sub cmd_Click(Index As Integer) Text1.Text = Text1.Text &cmd(Index).Caption curval = Val(Text1.Text) End Sub Private Sub cmdac_Click() curval = preval = 0 Text1.Text = "" End Sub Private Sub cmddiv_Click() Text1.Text = "" preval = curval curval = 0 choice = "/" End Sub Private Sub cmdequal_Click() Select Case choice Case "+" result = preval + curval Text1.Text = Str(result) Case "-" result = preval - curval Text1.Text = Str(result) Case "*" result = preval * curval Text1.Text = Str(result) Case "/" result = preval / curval Text1.Text = Str(result) End Select curval = result End Sub Private Sub CMDEXIT_Click() End End Sub Private Sub cmdminus_Click() Text1.Text = "" preval = curval curval = 0 choice = "-" End Sub Private Sub cmdmul_Click() Text1.Text = ...

SIMULATION OF SLIDING WINDOW PROTOCOLS USING C

SENDER #include<sys/socket.h> #include<sys/types.h> #include<netinet/in.h> #include<netdb.h> #include<stdio.h> #include<string.h> #include<stdlib.h> #include<unistd.h> #include<errno.h> int main() { int sock,bytes_received,connected,true=1,i=1,s,f=0,sin_size; char send_data[1024],data[1024],c,fr[30]=" "; struct sockaddr_in server_addr,client_addr; if((sock=socket(AF_INET,SOCK_STREAM,0))==-1) { perror("Socket not created"); exit(1); } if(setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,&true,sizeof(int))==-1) { perror("Setsockopt"); exit(1); } server_addr.sin_family=AF_INET; server_addr.sin_port=htons(17000); server_addr.sin_addr.s_addr=INADDR_ANY; if(bind(sock,(struct sockaddr *)&server_addr,sizeof(struct sockaddr))==-1) { perror("Unable to bind"); exit(1); } if(listen(sock,5)==-1) { perror("Listen"); exit(1); } fflush(stdout); sin_size=sizeof(st...

TCP SOCKET DATE AND TIME USING C

SERVER #include<stdio.h> #include<sys/types.h> #include<sys/socket.h> #include<netinet/in.h> #include<time.h> #include<string.h> #include<stdlib.h> #define max 30 #define PORT 2100 int main() { int sersoc,clisoc,conn,len,wri; char str[max]; pid_t pid; time_t ticks; socklen_t clilen; struct sockaddr_in servaddr,cliaddr; servaddr.sin_family=AF_INET; servaddr.sin_port=htons(PORT); servaddr.sin_addr.s_addr=htonl(INADDR_ANY); if((sersoc=socket(AF_INET,SOCK_STREAM,0))<0) { perror("Socket Error"); exit(0); } if(bind(sersoc,(struct sockaddr *)&servaddr,sizeof(servaddr))<0) { perror("Bind Error"); exit(0); } listen(sersoc,10); for(;;) { len=sizeof(cliaddr); conn=(accept(sersoc,(struct sockaddr *)&clisoc,&len)); if((pid=fork())==0) { close(sersoc); ticks=time(NULL); strcpy(str,ctime(&ticks)); if(wri==(write(conn,str,sizeof(str),0))<0) { printf("Write Error");...