Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder adarshakb's Avatar
    Join Date
    Jun 2009
    Location
    Silicon valley of india
    Posts
    247
    Thanks
    11
    Thanked 1 Time in 1 Post

    Exclamation Lazy to correct error... lol

    here is my prg
    Code:
    #include <iostream.h>
    #include <stdlib.h>
    #include <string.h>
    
    class dmy
    {
    private:
    	int d,m,y;
    public:
    	dmy()
    	{
    		d=m=y=0;
    	};
    	dmy(int dd,int mm,int yy)
    	{
    		d=dd;m=mm;y=yy;
    	};
    	int getDate()
    	{
    		return d;
    	};
    	int getMonth()
    	{
    		return m;
    	};
    	int getYear()
    	{
    		return y;
    	};
    	void disp()
    	{
    		cout<<"\n"<<d<<"/"<<m<<"/"<<y;
    	};
    };
    class date
    {
    private:
    	char d[9];
    public:
    	date()
    	{
    		strcpy(d,"1/1/2000");
    	}
    	date(char *p)
    	{
    		if(strlen(p)>9)
    		{
    			cout<<"Wrong Input";
    			return;
    		}
    		strcpy(d,p);
    	}
    	date(dmy x)
    	{
    		int d,m,y;
    		d=x.getDate();
    		m=x.getMonth();
    		y=x.getYear();
    
    		char tmp[4];
    		char ans[9];
    
    
    		itoa(d,tmp,10);
    		strcpy(ans,tmp);
    		strcat(ans,"/");
    		itoa(m,tmp,10);
    		strcat(ans,tmp);
    		strcat(ans,"/");
    		itoa(y,tmp,10);
    		strcat(ans,tmp);
    		
    		strcpy(this->d,ans);
    	}
    	
    	void disp()
    	{
    		cout<<"\n"<<d;
    	}
    };
    
    void main()
    {
    	date a;
    	dmy b(21,06,1990);
    
    	a=b;
    	a.disp();
    }
    and another one
    Code:
    #include <iostream.h>
    #include <string.h>
    #include <stdlib.h>
    
    class date
    {
    private:
    	char d[9];
    public:
    	date()
    	{
    		strcpy(d,"01/01/0000");
    	}
    	date(char *p)
    	{
    		if(strlen(p)>9)
    		{
    			cout<<"Bad input";
    			return;
    		}
    
    		strcpy(d,p);
    	}
    	void disp()
    	{
    		cout<<"\n"<<d;
    	}
    };
    class dmy
    {
    private:
    	int d,m,y;
    public:
    	dmy()
    	{
    		d=m=y=0;
    	}
    	dmy(int dd,int mm,int yy)
    	{
    		d=dd;m=mm;y=yy;
    	}
    	void disp()
    	{
    		cout<<"\n"<<d<<"/"<<m<<"/"<<y;
    	}
    	operator date()
    	{
    		char tmp[4];char ans[9];
    
    
    		itoa(d,tmp,10);
    		strcpy(ans,tmp);
    		strcat(ans,"/");
    		itoa(m,tmp,10);
    		strcat(ans,tmp);
    		strcat(ans,"/");
    		itoa(y,tmp,10);
    		strcat(ans,tmp);
    		return date(ans);
    	}
    };
    
    void main()
    {
    	dmy a(21,06,1990);
    	date b=a;
    	b.disp();
    }
    in the output i see some special char.. so if any are free correct this within 4-5hrs
    lol i am busy now so dint get time to correct it... np if no one replies

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    You're right: you are lazy. Maybe your prof will discover your laziness and reward you with a failing grade.
    Are you a Help Vampire?

  • #3
    Regular Coder
    Join Date
    May 2008
    Location
    Lost in Localhost...
    Posts
    702
    Thanks
    3
    Thanked 43 Times in 42 Posts
    This isn't a place to have programs made for you simply because you are lazy. Either post a paid request in the Marketplace, or start a new thread where you can work out you're problems with the help of others.

    Also see rule 1.5 in the Forum Rules.

    Now, you may ask for advice or help on a specific aspect of your assignment that you're having trouble with. Use common sense as far as what's acceptable in terms of soliciting help with homework assignments.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •