View Notes – Opp’s Notes(1).doc from CSE at Anna University Chennai – Regional Office, Coimbatore. CS OBJECT ORIENTED PROGRAMMING 3 0 . Anna University CS Object Oriented Programming Department of Computer Science Engineering and Information Technology (Regulation. Download CS Object Oriented Programming notes Anna University lecturer notes and QUESTION PAPER.

Author: Gugami Kazrazshura
Country: Nigeria
Language: English (Spanish)
Genre: Politics
Published (Last): 8 November 2018
Pages: 72
PDF File Size: 5.26 Mb
ePub File Size: 12.2 Mb
ISBN: 313-6-43859-177-2
Downloads: 70475
Price: Free* [*Free Regsitration Required]
Uploader: Jugami

Explain constructor overloading with example. Create oriened class Time and display hour, minute and seconds using constructor overloading. Constructor has same name as that of class and it does not have any return type. When the object of class temporary is created, constructor is called and x is initialized to 5 and y is initialized to 5.

You can also initialize data member inside the constructor’s oriejted body as below. But, this method is not preferred. Initializing all objects manually will be very tedious. Instead, you can define a constructor which initializes that data member to 0. Then all you have to do is define object and constructor will initialize object automatically. These types of situation arises obhect L.

Also, if you want to execute some codes immediately after object is created, you can place that code inside the body of constructor. DisplayArea temp ; return 0; Explanation In this program, a class of name Area is created to calculate the area of a rectangle. There are two data members length and breadth.

A constructor is defined which initializes length to 5 and breadth to 2. And, we have three additional member functions GetLengthAreaCalculation and DisplayArea to prrogramming length from user, calculate the area and display the area respectively.

Then the member function GetLength is invoked which takes the value of length and breadth from user for object A1. Then, the area for the object A1 is calculated and stored in variable temp by calling Ooriented function. And finally, ogiented area of object A1 is displayed. For object A2, no data is asked from the user.

So, the value of length will be 5 and breadth will be 2. Then, the area for A2 is calculated and displayed obbject is Output Enter length and breadth respectively: Overloaded constructors have same name name of the class but different number of argument passed.

Depending upon the number and type of argument passed, specific constructor is called. Since, constructor are called when object is created. Argument to the constructor also should be passed while creating object.

Here is the modification of above program to demonstrate the working of overloaded constructors. Thus, the constructor with no argument is invoked which initializes length to 5 and breadth to 2.


Hence, the area of object A1 will be For object A2, 2 lbject 1 is passed as argument. Thus, the constructor with two argument is called which initializes length to l 2 in this case and breadth to b 1 in this case. Hence the area of object A2 will be 2. Output Default Area when no argument is passed. Let us suppose the above program.

If you want to initialize a object A3 so that it contains orientde value as A2. Then, this can be performed as Explain the use of explicit constructors with an example program. In order to avoid such implicit conversions, a constructor that takes one argument can be declared explicit. Then the compiler performs an implicit conversion to convert from string data type to student object. To avoid such implicit conversions, a constructor that takes one argument can be declared explicit.

Write a program to overload a unary operator as a member function and also explain the operator overloading. Rules of operator overloading: Only the existing operator can be overloaded.

The overloaded operator must have at least one operand that is of user defined data type.

The basic meaning of the operator should not be changed. Overload operators follow the ooriented and orientsd rules of original operators. They cannot be priented. Except the function call operatorno other operator can have a default argument.

All operators having a single argument are unary operators. When we overload these operators as member functions, we do not need to pass any argument explicitly. The this pointer pointing to invoking object is passed as an implicit argument. Pre increment Pre increment Post increment 21 5 Example Write a program to perform complex number addition, subtraction, multiplication and division.

Enter real value There are three types of data conversions. Conversion from built-in data type to an object Conversion from object to a built-in data type Conversion from one object to another object type Any type conversion involving a class is defined either By a conversion constructor By a conversion operator function The conversion performs type conversion by converting any given type to the type of the current class.

A conversion operator function performs conversion in the opposite direction, that is, it converts an object of the current class to another type. It must be a member function It must not specify a return type It must not have any argument L. Conversion from basic data type to object type can be done with the help of constructors.


A constructor takes a single argument whose type is to be converted. Conversion from object to a built-in data type: Using the conversion function, conversion from object of a class to a built-in type can be done. The above conversion operator function can also be invoked explicitly as follows: If does not find one, then it looks for a conversion operator program,ing and involves the same implicitly for data conversion.

Conversion from one object to another object using conversion constructors: More About Classes Each object instance has its own copy.

CS Spring Jill Seaman 1 static variable: Sc2203 1 Obkect 1. What is the correct value to return to the operating system upon the successful completion of a program? Programs do not return oirented value. What is progrqmming only. Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common.

In the example above two functions are defined. Both increments the value of i by one, but fcn1 uses call-by-value as parameter passing mechanism and fcn2 uses call-by-reference. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage.


What does mean? How the computer interprets the string. Control Structure Normally, a program is executed in a sequential manner. Often programs that appear nonmathematical on the surface perform a large number of mathematical calculations behind the. Java JRE – Java is not just a programming language but it is a complete platform for object oriented programming. An idealised picture is: What is the most important feature of Java? Java is a platform independent language.

What do you mean by platform independence? Platform independence means that we can write and compile the java.

Introduction Computer is a device capable of performing computations and making logical decisions at speeds millions and even billions objeect times faster than human beings.

Computers process data under the. Programming is the process of writing a computer program in a language that the computer can respond to. Fill in the Blanks: A is a special member function used to initialize the data members of a class. The default access for members of a class is.

CS Object Oriented Programming – Lecture Notes (PPT)

Member functions of a class. Classes and Objects Week 5 Gaddis:. A class contains members: How does an enumerated statement differ from a typedef statement? What are the various members of a class?