Objects and Classes
1. Define a class to represent a string with operations string length, compare and reverse. Show its use by writing main().
3. Write a class called “arithmetic” having two integer and one character data members. It performs the operation on its integer members indicated by character member (+, -, *, /). For example * indicates multiplication on data members as d1 * d2. Write a class with all necessary constructors and methods to perform the operation and print the operation performed in format Ans = d1 op d2. Test your class using main().
4. Define Class named point which represents 2-D Point, i.e P(x,y). Define Default Constructor to initialize both data member value 5, Parameterized constructor to initialize member according to value supplied by user and Copy Constructor.Define Necessary Function and Write a program to test class Point.
5. Create a class Account. It has three data member account id, name and balance. Define function to assign value and display value. Define function that search account number given by the user. If account number exists, print detail of that account. Write a program using array of object. Declare at least 5 account and print details .
No comments:
Post a Comment