Skip to main content

Multiple Inheritance


#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<dos.h>
#include<iomanip.h>

class time1
{
protected:
int hr,min,sec;
public:
time1(int h,int m,int s);

};
class date1
{
protected:
int dt,mon,yr;
public:
date1(int d,int m1,int y);
};

class clock:public time1,public date1
{
char str[3];
public:
clock(int h,int m,int s,int d,int m1,int y);
void showclock();
void inc();
};

time1::time1(int h,int m,int s)
{
hr=h;min=m;sec=s;
}

date1::date1(int d,int m1,int y)
{
dt=d;mon=m1;yr=y;
}

clock::clock(int h,int m,int s,int d,int m1,int y):time1(h,m,s),date1(d,m1,y)
{
}

void clock::showclock()
{
gotoxy(10,10);
cout<<setw(2)<<hr<<":"<<setw(2)<<min<<":"<<setw(2)<<sec<<str;
gotoxy(10,12);
cout<<dt<<":"<<mon<<":"<<yr<<endl;
}
void clock::inc()
{
sec++;
if(sec>=60)
{
sec=0;
min++;
}
if(min>=60)
{
min=0;
hr++;
}
if(hr>=12)
strcpy(str,"PM");
else
strcpy(str,"AM");
}
void main()
{
clrscr();
clock t(11,59,45,29,6,2009);
clrscr();
gotoxy(10,8);
cout<<"Digital Clock";
while(!kbhit())
{
t.showclock();
delay(10);
t.inc();
}
}

Comments

Popular posts from this blog

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...

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 = ...

TCP SOCKETS CHAT APPLICATION(SERVER & CLIENT) USING C

SERVER #include<stdio.h> #include<netinet/in.h> #include<sys/types.h> #include<sys/socket.h> #include<netdb.h> #include<stdlib.h> #include<string.h> #define MAX 80 #define PORT 43454 #define SA struct sockaddr void func(int sockfd) { char buff[MAX]; int n; for(;;) { bzero(buff,MAX); read(sockfd,buff,sizeof(buff)); printf("From client: %s\t To client : ",buff); bzero(buff,MAX); n=0; while((buff[n++]=getchar())!='\n'); write(sockfd,buff,sizeof(buff)); if(strncmp("exit",buff,4)==0) { printf("Server Exit...\n"); break; } } } int main() { int sockfd,connfd,len; struct sockaddr_in servaddr,cli; sockfd=socket(AF_INET,SOCK_STREAM,0); if(sockfd==-1) { printf("socket creation failed...\n"); exit(0); } else printf("Socket successfully created..\n"); bzero(&servaddr,sizeof(servaddr)); servaddr.sin_family=AF_...