You feel excited to learn computer languages

Then you are at the right place. Computer languages are most fun thing you have ever seen. Use this excellent languages and have a nice future...

How computer can help you?

I will ask how it can not? From the latest trend of social networking sites like Facebook, Twitter to the extended use of computer in our house hold devices. You can be benefited from computer in the every aspect of life.

What web technology?

It is the blessings of web technology, that brings you here and you are reading my post now. Strange huh!! Not at all. Use my web technology tutorials and understand, how they can help you for better marketing and advertising systems.

How Mobile technology can help us?

You have answer right? I know. But in my tutorials I will cover some unique features that may add some information in your hard disk too. Sounds good? Check them...

Computer and future

Yes that is the most important question to me. What is next? What is going to be the next big thing for us? Well I will answer them in my blog. Check the corresponding section..

Showing posts with label constructor. Show all posts
Showing posts with label constructor. Show all posts

Monday, November 7, 2011

Manage Car model Using C++


Using this program you can have basic knowledge of Constructor, enum, basic class construction, meber function details.

#include<iostream.h>
 #include<conio.h>
 enum COLOR{red,blue,green,black,white};
 typedef char * String;
 class car
 {
private:
COLOR color;
float price;
String company;
public:
car();
car(COLOR,float,String);
void showvalue() const;
 };
 car::car():
color(white),
price(0.0),
company("")
{}
 car::car(COLOR c,float p,String com)
 {
this->color=c;
this->price=p;
company=com;
 }
 void car::showvalue() const
 {
cout<<"This "<<color<<" of "
<<company<<" is for "<<price<<" Rs."<<endl;
 }
 class complex
 {
private:
int real;
int com;
public:
complex(int,int);
complex();
void showvalue() const;
//void operator++ ();
complex operator++ ();
complex operator++ (int);
complex operator+(const complex c);
 };
 complex::complex():
real(0),com(0){}
 void complex::showvalue() const
 {
cout<<real<<"+"<<com<<"i"<<endl;
 }
 complex::complex(int a,int b):
real(a),com(b){}
 complex complex::operator++()
 {
complex c(0,0);
real++;
c.real=real;
return c;
 }
 complex complex::operator+(const complex c)
 {
complex a;
a.real=real+c.real;
a.com=com+c.com;
return a;
 }
 complex complex::operator++(int)
 {
complex c;
c=*this;
real++;
return c;
 }
 void main()
 {
complex c1(1,2),c2(2,3);
clrscr();
c1.showvalue();
++c1;
c1.showvalue();
complex c3=c1++;
c3.showvalue();
c1.showvalue();
complex c4;
c4=c1+c2;
cout<<endl<<endl;
c1.showvalue();
c2.showvalue();
c4.showvalue();
getch();
 }