Skip to main content

CONSTRUCTOR AND DESTRUCTOR


#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
#include<dos.h>
class time1
{
int *rem;
int m,s;
public:
time1();
~time1();
};
void time1::time1()
{
rem=new int;
cout<<"\n\tCountdown timer";
cout<<"\n\tEnter the time in minutes:";
cin>>m;
cout<<"\n\tEntr time in seconds";
cin>>s;
cout<<"\n\tpress any key to start!!";
getch();
clrscr();
cout<<"\n\tTimer:";
cout<<"\n\tRemaining Time is :";
cout<<"\n\tPress shift +break to pause";
cout<<"\n\tPress cntrl + any key to Resume\n\t";
for(rem=&s;*rem>=0;(*rem)--)
{
sleep(2);
cout<<"\t\r"<<setw(1)<<m<<":"<<setw(2)<<*rem;
}
for(int min=m;min>0;min--)
{
for(int sec=59;sec>=0;sec--)
{
sleep(2);
cout<<"\t\r"<<setw(1)<<min-1<<":"<<setw(2)<<sec;
}
}
cout<<"\n\tEnded";
}
time1::~time1()
{
clrscr();
delete rem;
cout<<"\n\n\tconstructor memory is destroyed:";
cout<<*rem;
}
void main()
{
time1 t;
}

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