Skip to main content

Posts

Showing posts from June, 2010

Class Point:: It holds co-ordinates of a point in format (x,y)

A class Named "Point" which stores the Co-ordinates of a point in (x,y) Format. This Class Contains:: O Constructor with default arguments O Copy Constructor O Function to display which Co-ordinate a Point belongs to O Function to get value of x of a point O Function to get value of y of a point O Function to get the Radious Vector (r) of a point O Function to get the Theta of a point O Overloaded Operator - to find out distance between two points O Overloaded Operator >> to take input O Overloaded operator << to display a point O Destructor #include<iostream.h> #include<math.h> class point{ //Data Members int x,y; //They hold the value of X and Y co-ordinate of a Point. public: //Member Functions point(int t1=0, int t2=0) //Constructor with default arguments. { x=t1; y=t2; } point(point &t) //Copy Constructor { x=t.x; y=t.y; } int coordinate(void); //It returns the point's Co-ordinate, e.g.,

IntArray Class Definition:: It can hold an array of Integer with Diffrent Size

A Class named ' intarray ' which can store an integer array of different size. This Class contains:: O Constructor with deafault argument value At the time of Object creation if array size is missing then An array of size 0 will be created. O Copy Constructor This Constructor is used to create a new Object from an existing Object. O Overloaded Operator = This operator is overloaded to assign an intarray object into another object, simply as two integer variables can be made. O Overloading Operator [ ] As array element can be reffered by its position declaring in Subscript operator ( [ ] ), here every element of an object array can be reffered by [ ] operator. O Overloading Operator >> This is an input operator . Here we can take input to a object simply by this line cin >> a; . Here a is an intarray object. O Overloading Operator << This is an output operator . Here we can get the output of an intarray object by this line cout << a; . Here