UNIT POLYMORPHISM

Size: px
Start display at page:

Download "UNIT POLYMORPHISM"

Transcription

1 UNIT POLYMORPHISM CONTENTS 3.1. ADT Conversions 3.2. Overloading 3.3. Overloading Operators 3.4. Unary Operator Overloading 3.5. Binary Operator Overloading 3.6. Function Selection 3.7. Pointer Operators 3.8. Visitation 3.9. Iterators Containers List List Iterators Objective Questions Key Term Quiz Review Questions 1

2 3.1. ADT Conversions Explicit type conversion of an expression is necessary when either the implicit conversions are not desired or the expression will not otherwise be legal. One aim of OOP using C++ is the integration of user-defined ADTs and built-in types. To achieve this, there is a mechanism for having a member function provide an explicit conversion. For example, we can convert from an already-defined type to a user-defined type: my_string::my_string(const char* p); This is automatically a type conversion from char* to my_string. It is available both explicitly and implicitly. Explicitly, it is used as a conversion operation in either cast or functional form. Thus, both of the following pieces of code work: my_string s; char* logo = "Geometrics Inc"; s = static_cast<my_string>(logo); and s = logo; //implicit invocation of conversion 3.2. Overloading i) C++ permits the use of two function with the same name. However such functions essentially have different argument list. The difference can be in terms of number or type of arguments or both. ii) This process of using two or more functions with the same name but differing in the signature is called function overloading. iii) But overloading of functions with different return types are not allowed. iv) In overloaded functions, the function call determines which function definition will be executed. v) The biggest advantage of overloading is that it helps us to perform same operations on different datatypes without having the need to use separate names for each version. #include<iostream> using namespace std; int abslt(int ); long abslt(long ); float abslt(float ); double abslt(double ); int main() { int intgr=-5; long lng=34225; float flt=-5.56; double dbl= ; 2

3 cout<<\" absoulte value of \"<<intgr<<\" = \"<<abslt(intgr)<<endl; cout<<\" absoulte value of \"<<lng<<\" = \"<<abslt(lng)<<endl; cout<<\" absoulte value of \"<<flt<<\" = \"<<abslt(flt)<<endl; cout<<\" absoulte value of \"<<dbl<<\" = \"<<abslt(dbl)<<endl; int abslt(int num) { if(num>=0) return num; else return (-num); long abslt(long num) { if(num>=0) return num; else return (-num); float abslt(float num) { if(num>=0) return num; else return (-num); double abslt(double num) { if(num>=0) return num; else return (-num); Overloading Operators When an operator is used for different operations, such process is called operator overloading. In C pointer operator * is used to declare pointer variable as well as it is used for multiplication expression. Similarly in C++ << is used display values of different data types without specifying any format code, like in C. The same operator is also used in bit wise operation. cout <<77.45; cout<< This is C++; It is a special mechanism which gives a special meaning to the operator by the user definition. When an operator is overloaded, none of its original meanings are lost. The general form of a member operator function is: ret-type class name:: operator #(arg_list) { //oprations Here ret-type -> type of an object # -> is a placeholder to place any operator. Arg-list -> none fro unary operator and one for binary operator. There are mainly four in operator overloading. What are the rules for operator overloading? I. Only existing operator overloading. II. The overloaded operator must have at least one operand that is of user-defined type. III. The semantics of an operator can be extended, but we cannot change its syntax.

4 IV. Overloaded operators follow the syntax rules of the original operators that cannot be overidedon. Restrictions on operator overloading We cannot alter the precedence of an operator. We cannot change the number of operands that an operator takes we can choose or ignore an operand. Except for the function call operator, operator functions cannot have default arguments. What are the operators cannot be overloaded? Why? The following operators cannot be overloaded.. -> member operator :: -> scope resolution operator.* -> member selection through pointer to member? -> conditional operator Size of and typeid -> named operators They take name, rather than a value, as their second operand and provide the primary means of referring to members. Allowing them to be overloaded would lead to subtleties Unary Operator Overloading A unary operator, whether prefix or postfix, can be defined by either a non static member function taking no arguments or a non member function taking one argument. for any prefix unary operator #,#aa can be interpreted as either aa.operator #( ) or operator #(aa).for any postfix unary operator #,aa# can be interpreted as either aa.operator #(int) to operator #(aa.int).for anycase,if they are defined, overload resolution determines which, if any, interpretation is used. For example class x { x*operator& ( ); / / prefix unary& / / (address of) x operator&(x); / /binary & (and) : : ; x operator (x, x); / / binary minus x operator (x); / / prefix unary minus #include<iostream.h> Program to find the complex numbers using unary operator overloading #include<conio.h> class complex { int a,b,c; public: complex(){ void getvalue() { cout<<"enter the Two Numbers:"; cin>>a>>b;

5 void operator++() { a=++a; b=++b; void operator--() { a=--a; b=--b; void display() { cout<<a<<"+\t"<<b<<"i"<<endl; ; void main() { clrscr(); complex obj; obj.getvalue(); obj++; cout<<"increment Complex Number\n"; obj.display(); obj--; cout<<"decrement Complex Number\n"; obj.display(); getch(); Output: Enter the two numbers: 3 6 Increment Complex Number 4 + 7i Decrement Complex Number 3 + 6i 3.5. Binary Operator Overloading A binary operator can be defined by either a non-static member function taking one argument or a non member function taking two arguments. For any binary operator #, aa#bb can be interpreted as either aa.operator # (bb) or operator #(aa, bb).if both are defined, overload resolution determine which, if any, interpretation is used. For example class x { public: Void operator +(int); / / member operator / / function * x (int); ; void operator +(x, x); / / non member operator / / function Program to add two complex numbers using binary operator overloading #include<iostream.h> #include<conio.h> 5

6 class complex { int a,b; public: void getvalue() { cout<<"enter the value of Complex Numbers a,b:"; cin>>a>>b; complex operator+(complex ob) { complex t; t.a=a+ob.a; t.b=b+ob.b; return(t); complex operator-(complex ob) { complex t; t.a=a-ob.a; t.b=b-ob.b; return(t); void display() { cout<<a<<"+"<<b<<"i"<<"\n"; ; void main() { clrscr(); complex obj1,obj2,result,result1; 6 obj1.getvalue(); obj2.getvalue(); result = obj1+obj2; result1=obj1-obj2; cout<<"input Values:\n"; obj1.display(); obj2.display(); cout<<"result:"; result.display(); result1.display(); getch(); Output: Enter the value of Complex Numbers a, b 4 5 Enter the value of Complex Numbers a, b 2 2 Input Values 4 + 5i 2 + 2i

7 Result 6 + 7i 2 + 3i comma operator: The comma operator is a binary operator. We can make an overloaded comma perform any operation we want. If we want the overloaded comma to perform in a fashion similar to its normal operation, then our version must discard the values of all operands except the right most. The right most value becomes the result of the comma operator Function Selection FUNCTION SELECTION The Overloaded meaning is selected by matching the argument list of the function call to the argument list of the function declaration. When an overloaded function is invoked, the compiler must have a selection algorithm with which to pick the appropriate function. The algorithm that accomplishes this depends on what type conversions are available. A best match must be unique. It must be best on at least one argument and as good as any other match on all other arguments. Overloaded function selection algorithm: 1. Use an exact matches if found. 2. Try standard type promotions 3. Try standard type conversions. 4. Try user-defined conversions. 5. Use a match to ellipsis if found. Standard promotions are better than other standard conversions. These are conversions from float to double, and from bool, char, short or enum to int. Standard conversions also include pointer conversions. An exact match is clearly best Pointer Operators Overloading > The > pointer operator, also called the class member access operator, is considered a unary operator when overloading. Its general usage is shown here: object->element; Here, object is the object that activates the call. The operator >() function must return a pointer to an object of the class that operator >() operates upon. The element must be some member accessible within the object. 7

8 The following program illustrates overloading the > by showing the equivalence between ob.i and ob >i when operator >() returns the this pointer: #include <iostream> using namespace std; class myclass { public: int i; myclass *operator->() {return this; ; int main() { myclass ob; ob->i = 10; // same as ob.i cout << ob.i << " " << ob->i; return 0; An operator >() function must be a member of the class upon which it works Visitation Container classes are used to hold a large number of individual items. The types STACK and VECT are two such container classes. Many of the operations on container classes involve the ability to visit individual elements conveniently. There are variety of techniques to perform visitation and the extraction of elements from a class. One technique is to create iterator whose function is to visit the elements of an object in a container class. The iterator navigates over the elements of the class. Using visitation as the theme, we can write code that anticipates using the container classes and iterator objects and algorithms found in the standard template library. Conventional programming uses the for statement as its preferred means of structuring iteration, especially when processing arrays. //visit each a[i] and do something for (i=0;i<size;i++) sum+ = a[i]; The for statement specifies a specific order of visitation and is controlled by an index i, which is visibly modified. The order of visitation and the index used are generally details of implementation that do not affect the computation. 8

9 3.9. Iterators Visitation of the elements of an aggregate is a fundamental operation. When the aggregate is a class, an elegant solution to providing visitation operations is to create a separate but related class, called an iterator class, whose function is to visit and retrieve elements from aggregate. Iterators: An iterator is an object that can iterate or navigate or traverse over elements in the containers that represent data structures. These elements may be the entire or just a portion of a STL container. It represents a certain position in a container. Interators are object that are, more or less, pointers. They give the ability to cycle through the contents of a container in much same way that we would use of a pointer to cycle through an array. Since iterators are pointers, we can increment and decrement them and also apply the *operator to them.iterators are declared using the iterator type defined by the various containers. Five types of iterators: The following are the five types of iterators: Iterator Random Access Bi-directional Forward Input Output Access Allowed Store and retrieve values. Elements may be accessed randomly. Store and retrieve values. Forward and Backward moving. Store and retrieve values. Forward moving only. Retrieve, but not store values. Forward moving only. Store, but not retrieve values. Forward moving only Containers STL: The STL is a complex piece of software engineering that uses some of C++ s most sophisticated features. It provides general purpose, templatized classes and functions that implement many popular and commonly used algorithms and data structures like vectors, stacks, queues and lists. It also defines various routines that access them. are the foundational items of STL? I. Containers The three foundational items of standard library are: II. Algorithms III. Iterators 9

10 Container: A class holding a collection of elements of some type is commonly called a container class, or simply a container. The container is objects that hold other objects, and there are several different types. Each container class defines a set of functions that may be applied to the container. Two types of container: There are two types of containers. I. Sequence container: It provides a linear access on the elements. For example vector Class. dequq class and list class are sequence containers. ii. Associative container: It allow efficient retrieval of values based on keys. For Example, map, multi map, set and multi set. Common functions can be used in container: I. insert ( ) used to insert element into both container. II. erase ( ) used to removes elements from both container. III. push_back ( ) used to add an element to the end in a sequence container. IV. push_front ( ) used to add an element to the beginning of a sequence container. V. pop_back ( ) which removes elements from the end of the sequence container. VI. pop_front ( ) which removes elements from the start of the sequence container. VII. begin ( ) and end ( ) which returns iterators to start and end of the both container. VIII. find ( ) which is used to locate an element in an associative container given its key List List and its template: A list is a bi-directional linear list, which can be accessed sequentially only. A list has this template specification template <class T, class Allocator=allocator<T>> class list Here, T is the type of data stored into in the list. The allocator is specified by allocator which defaults to the standard allocator. constructors of a list: The list has the following constructors: explicit list (const Allocator &a, Allocator ( )); explicit list (size_type num, const T &val =T ( ), const Allocator 7a Allocator ( )); list (const list <T, Allocator > &ob); template <class InIter>list (InIter start,initer end,const Allocator &a =Allocator ( )); The first form constructs an empty list. The second form constructs a list that has num elements with the value val, which can be allowed to be default. The third form constructs a list that contains the same elements as ob.the fourth from constructs a list that contains the elements the in the range specified by the iterators start and end. Differentiate vector and list. Vector i). It has random-access. ii). It is created using dynamic allocation method. List i. It has sequential access. ii. It is created statically. 10

11 iii). Insertions and deletions are trade away iv). The accessing speed is very high v). It is uni-directional list. iii.the Insertions and deletion are low-cost iv. The accessing speed is very low. v. It is bi-directional list List Iterators. Example 1: // an iterator, a list container simple example #include <iostream> #include <list> using namespace std; int main() { // lst, list container for character elements list<char> lst; // append elements from 'A' to 'Z' to the list lst container for(char chs='a'; chs<='z'; ++chs) lst.push_back(chs); // iterate over all elements and print, separated by space list<char>::const_iterator pos; for(pos = lst.begin(); pos!= lst.end(); ++pos) cout<<*pos<<' '; cout<<endl; return 0; Example 2: // list_begin.cpp // compile with: /EHsc #include <list> #include <iostream> int main( ) { using namespace std; list <int> c1; list <int>::iterator c1_iter; list <int>::const_iterator c1_citer; c1.push_back( 1 ); c1.push_back( 2 ); c1_iter = c1.begin( ); cout << "The first element of c1 is " << *c1_iter << endl; *c1_iter = 20; c1_iter = c1.begin( ); cout << "The first element of c1 is now " << *c1_iter << endl; // The following line would be an error because iterator is const // *c1_citer = 200; 11

12 Friend Function Friend Function: A friend function is used for accessing the non-public members of a class. A class can allow nonmember functions and other classes to access its own private data, by making them friends. Thus, a friend function is an ordinary function or a member of another class. Defining Friend Function in C++: The friend function is written as any other normal function, except the function declaration of these functions is preceded with the keyword friend. The friend function must have the class to which it is declared as friend passed to it in argument. Some important points to note while using friend functions in C++: The keyword friend is placed only in the function declaration of the friend function and not in the function definition. It is possible to declare a function as friend in any number of classes. When a class is declared as a friend, the friend class has access to the private data of the class that made this a friend. A friend function, even though it is not a member function, would have the rights to access the private members of the class. It is possible to declare the friend function as either private or public. The function can be invoked without the use of an object. The friend function has its argument as objects, seen in example below. Example: To find the mean value of a given number using friend function. #include<iostream.h> #include<conio.h> class base { int val1,val2; public: void get() { cout<<"enter two values:"; cin>>val1>>val2; friend float mean(base ob); ; float mean(base ob) { return float(ob.val1+ob.val2)/2; void main() { clrscr(); base obj; obj.get(); cout<<"\n Mean value is : "<<mean(obj); getch(); 12

13 There are two methods by which operators can be overloaded, one using the member function and the other by using friend functions. Binary Operator overloading using friend function: Example: // Using friend functions to overload addition and subtraction operators #include <iostream.h> class myclass { int a; int b; public: myclass(){ myclass(int x,int y){a=x;b=y; void show() { cout<<a<<endl<<b<<endl; // these are friend operator functions // NOTE: Both the operands will be passed explicitly. // operand to the left of the operator will be passed as the first argument and operand to the right as the second argument friend myclass operator+(myclass,myclass); friend myclass operator-(myclass,myclass); ; myclass operator+(myclass ob1,myclass ob2) { myclass temp; temp.a = ob1.a + ob2.a; temp.b = ob1.b + ob2.b; return temp; myclass operator-(myclass ob1,myclass ob2) { myclass temp; temp.a = ob1.a - ob2.a; temp.b = ob1.b - ob2.b; return temp; void main() { myclass a(10,20); myclass b(100,200); a=a+b; a.show(); a=a-b; a.show(); Unary Operator overloading using friend function: Example: #include<iostream.h> #include<conio.h> class complex { 13

14 int a,b,c; public: complex(){ void getvalue() { cout<<"enter the Two Numbers:"; cin>>a>>b; void display() { cout<<a<<"+\t"<<b<<"i"<<endl; friend void operator++(); friend void operator--(); ; void operator++() { a=++a; b=++b; void operator--() { a=--a; b=--b; void main() { clrscr(); complex obj; obj.getvalue(); obj++; cout<<"increment Complex Number\n"; obj.display(); obj--; cout<<"decrement Complex Number\n"; obj.display(); getch(); Objective Questions 1. This process of using two or more functions with the same name but differing in the signature is called. a) Function overloading b)overloading c)operator overloading d) none 2. The keyword is also used to overload the built-in C++ operators. a) Overload b) operator c) both d) none 3. is one of the technique to perform visitation. a) b) c)iteration d) 4. Containers should designate a an member returning an iterator. a) Begin() b)end() c)both d) none 14

15 5. When a unary operator is overloaded using a member function, it has an argument list because the single operator argument is the implicit argument. a) empty b)single c)double d) single (or) double Key Term Quiz Key Terms: ( Container, list, STL, Iterators, visitation) Key Term Quiz: 1. A class holding a collection of elements of some type is commonly called a container class, or simply a. 2. A is a bi-directional linear list, which can be accessed sequentially only. 3. provides general purpose, templatized classes and functions that implement many popular and commonly used algorithms and data structures like vectors, stacks, queues and lists. 4. are either pointers or pointer-like objects. 5. Using as the theme, we can write code that anticipates using the container classes and iterator objects and algorithms found in the standard template library Review Questions PART A (2 Marks) 1. List the operations cannot used in overloading. 2. What is an iterator? What are its characteristics? 3. When you overload member function in what ways must they differ? 4. Define polymorphism. 5. Define binary operator. 6. Define Unary operator. 7. What are the rules for operator overloading? 8. What is meant by overloading? PART B (16 Marks) 1. Explain the operator overloading of Binary Operators in c++ with suitable example. 2. What is meant by function overloading? Write the rules associated with function overloading. Give suitable example to support your answer. 3. Consider two classes Employee, Manager with id and basic pay as data members and input and output member functions to get details and display tax. Write a friend function income tax to operate on the objects of both thses classes to calculate tax. 15

16 4. Write a inline function to find square of a number. 5. Write a program to overload + operator to add two Matrix objects and store results in another object. 6. Design a class Complex No. Using Operator Overloading wrire the routines to implement the operations add, sub, mul and div. 7. Design a class List and enumerate its member functions with the implementation of any three of them. 8. How will you overload unary and binary operators using friend functions? Explain with sample code. 9. (i) List out the operators that cannot be overloaded using friend function. (ii) What is meant by casting operator? Write the general form of overloaded casting operator. (iii) Write at least four rules for operator overloading. 16

Module Operator Overloading and Type Conversion. Table of Contents

Module Operator Overloading and Type Conversion. Table of Contents 1 Module - 33 Operator Overloading and Type Conversion Table of Contents 1. Introduction 2. Operator Overloading 3. this pointer 4. Overloading Unary Operators 5. Overloading Binary Operators 6. Overloading

More information

Data type of a pointer must be same as the data type of the variable to which the pointer variable is pointing. Here are a few examples:

Data type of a pointer must be same as the data type of the variable to which the pointer variable is pointing. Here are a few examples: Unit IV Pointers and Polymorphism in C++ Concepts of Pointer: A pointer is a variable that holds a memory address of another variable where a value lives. A pointer is declared using the * operator before

More information

OBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak

OBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak OBJECT ORIENTED PROGRAMMING Ms. Ajeta Nandal C.R.Polytechnic,Rohtak OBJECT ORIENTED PARADIGM Object 2 Object 1 Data Data Function Function Object 3 Data Function 2 WHAT IS A MODEL? A model is an abstraction

More information

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++

More information

CS35 - Object Oriented Programming

CS35 - Object Oriented Programming Syllabus CS 35 OBJECT-ORIENTED PROGRAMMING 3 0 0 3 (Common to CSE & IT) Aim: To understand the concepts of object-oriented programming and master OOP using C++. UNIT I 9 Object oriented programming concepts

More information

C++ 8. Constructors and Destructors

C++ 8. Constructors and Destructors 8. Constructors and Destructors C++ 1. When an instance of a class comes into scope, the function that executed is. a) Destructors b) Constructors c) Inline d) Friend 2. When a class object goes out of

More information

M.C.A DEGREE EXAMINATION,NOVEMBER/DECEMBER 2010 Second Semester MC 9222-OBJECT ORIENTED PROGRAMMING (Regulation 2009)

M.C.A DEGREE EXAMINATION,NOVEMBER/DECEMBER 2010 Second Semester MC 9222-OBJECT ORIENTED PROGRAMMING (Regulation 2009) M.C.A DEGREE EXAMINATION,NOVEMBER/DECEMBER 2010 MC 9222-OBJECT ORIENTED PROGRAMMING (Regulation 2009) Max:100 Marks 1. How are data and function organized in an object oriented programming? 2. Compare

More information

Darshan Institute of Engineering & Technology for Diploma Studies

Darshan Institute of Engineering & Technology for Diploma Studies 1. Explain Call by Value vs. Call by Reference Or Write a program to interchange (swap) value of two variables. Call By Value In call by value pass value, when we call the function. And copy this value

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

2. Distinguish between a unary, a binary and a ternary operator. Give examples of C++ operators for each one of them.

2. Distinguish between a unary, a binary and a ternary operator. Give examples of C++ operators for each one of them. 1. Why do you think C++ was not named ++C? C++ is a super set of language C. All the basic features of C are used in C++ in their original form C++ can be described as C+ some additional features. Therefore,

More information

Introduction to C++ Systems Programming

Introduction to C++ Systems Programming Introduction to C++ Systems Programming Introduction to C++ Syntax differences between C and C++ A Simple C++ Example C++ Input/Output C++ Libraries C++ Header Files Another Simple C++ Example Inline Functions

More information

C++_ MARKS 40 MIN

C++_ MARKS 40 MIN C++_16.9.2018 40 MARKS 40 MIN https://tinyurl.com/ya62ayzs 1) Declaration of a pointer more than once may cause A. Error B. Abort C. Trap D. Null 2Whice is not a correct variable type in C++? A. float

More information

CHAPTER 4 FUNCTIONS. 4.1 Introduction

CHAPTER 4 FUNCTIONS. 4.1 Introduction CHAPTER 4 FUNCTIONS 4.1 Introduction Functions are the building blocks of C++ programs. Functions are also the executable segments in a program. The starting point for the execution of a program is main

More information

THE NAME OF THE CONSTRUCTOR AND DESTRUCTOR(HAVING (~) BEFORE ITS NAME) FUNCTION MUST BE SAME AS THE NAME OF THE CLASS IN WHICH THEY ARE DECLARED.

THE NAME OF THE CONSTRUCTOR AND DESTRUCTOR(HAVING (~) BEFORE ITS NAME) FUNCTION MUST BE SAME AS THE NAME OF THE CLASS IN WHICH THEY ARE DECLARED. Constructor and Destructor Member Functions Constructor: - Constructor function gets invoked automatically when an object of a class is constructed (declared). Destructor:- A destructor is a automatically

More information

W3101: Programming Languages C++ Ramana Isukapalli

W3101: Programming Languages C++ Ramana Isukapalli Lecture-6 Operator overloading Namespaces Standard template library vector List Map Set Casting in C++ Operator Overloading Operator overloading On two objects of the same class, can we perform typical

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

More information

CS304 Object Oriented Programming Final Term

CS304 Object Oriented Programming Final Term 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes? Generalization (pg 29) Sub-typing

More information

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR 603203 DEPARTMENT OF COMPUTER SCIENCE & APPLICATIONS QUESTION BANK (2017-2018) Course / Branch : M.Sc CST Semester / Year : EVEN / II Subject Name

More information

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers

More information

PESIT Bangalore South Campus

PESIT Bangalore South Campus USN 1 P E PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of ECE INTERNAL ASSESSMENT TEST 2 Date : 03/10/2017 Marks: 40 Subject & Code : Object Oriented Programming

More information

Object Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year

Object Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year Object Oriented Programming Assistant Lecture Omar Al Khayat 2 nd Year Syllabus Overview of C++ Program Principles of object oriented programming including classes Introduction to Object-Oriented Paradigm:Structures

More information

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9 Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits

More information

OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES

OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES Polymorphism: It allows a single name/operator to be associated with different operations depending on the type of data passed to it. An operation may exhibit different behaviors in different instances.

More information

1. The term STL stands for?

1. The term STL stands for? 1. The term STL stands for? a) Simple Template Library b) Static Template Library c) Single Type Based Library d) Standard Template Library Answer : d 2. Which of the following statements regarding the

More information

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a.

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a. Intro to OOP - Object and class - The sequence to define and use a class in a program - How/when to use scope resolution operator - How/when to the dot operator - Should be able to write the prototype

More information

Chapter 8. Operator Overloading, Friends, and References. Copyright 2010 Pearson Addison-Wesley. All rights reserved

Chapter 8. Operator Overloading, Friends, and References. Copyright 2010 Pearson Addison-Wesley. All rights reserved Chapter 8 Operator Overloading, Friends, and References Copyright 2010 Pearson Addison-Wesley. All rights reserved Learning Objectives Basic Operator Overloading Unary operators As member functions Friends

More information

AN OVERVIEW OF C++ 1

AN OVERVIEW OF C++ 1 AN OVERVIEW OF C++ 1 OBJECTIVES Introduction What is object-oriented programming? Two versions of C++ C++ console I/O C++ comments Classes: A first look Some differences between C and C++ Introducing function

More information

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols. EEE-117 COMPUTER PROGRAMMING Basic Elements of C++ Objectives General Questions Become familiar with the basic components of a C++ program functions, special symbols, and identifiers Data types Arithmetic

More information

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...

More information

Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team

Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team Question No: 1 ( Marks: 2 ) Write a declaration statement for an array of 10

More information

C++ Programming: From Problem Analysis to Program Design, Third Edition

C++ Programming: From Problem Analysis to Program Design, Third Edition C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 2: Basic Elements of C++ Objectives (continued) Become familiar with the use of increment and decrement operators Examine

More information

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

CONSTRUCTORS AND DESTRUCTORS

CONSTRUCTORS AND DESTRUCTORS UNIT-II CONSTRUCTORS AND DESTRUCTORS Contents: Constructors Default constructors Parameterized constructors Constructor with dynamic allocation Copy constructor Destructors Operator overloading Overloading

More information

Outline. User-dened types Categories. Constructors. Constructors. 4. Classes. Concrete classes. Default constructor. Default constructor

Outline. User-dened types Categories. Constructors. Constructors. 4. Classes. Concrete classes. Default constructor. Default constructor Outline EDAF50 C++ Programming 4. Classes Sven Gestegård Robertz Computer Science, LTH 2018 1 Classes the pointer this const for objects and members Copying objects friend inline 4. Classes 2/1 User-dened

More information

Abstract Data Types (ADTs) 1. Legal Values. Client Code for Rational ADT. ADT Design. CS 247: Software Engineering Principles

Abstract Data Types (ADTs) 1. Legal Values. Client Code for Rational ADT. ADT Design. CS 247: Software Engineering Principles Abstract Data Types (ADTs) CS 247: Software Engineering Principles ADT Design An abstract data type (ADT) is a user-defined type that bundles together: the range of values that variables of that type can

More information

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program 1 By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program variables. Apply C++ syntax rules to declare variables, initialize

More information

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay C++ Basics Data Processing Course, I. Hrivnacova, IPN Orsay The First Program Comments Function main() Input and Output Namespaces Variables Fundamental Types Operators Control constructs 1 C++ Programming

More information

PART I. Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++.

PART I.   Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++. Unit - III CHAPTER - 9 INTRODUCTION TO C++ Choose the correct answer. PART I 1. Who developed C++? (a) Charles Babbage (b) Bjarne Stroustrup (c) Bill Gates (d) Sundar Pichai 2. What was the original name

More information

CS 247: Software Engineering Principles. ADT Design

CS 247: Software Engineering Principles. ADT Design CS 247: Software Engineering Principles ADT Design Readings: Eckel, Vol. 1 Ch. 7 Function Overloading & Default Arguments Ch. 12 Operator Overloading U Waterloo CS247 (Spring 2017) p.1/17 Abstract Data

More information

TEMPLATES AND EXCEPTION HANDLING

TEMPLATES AND EXCEPTION HANDLING CONTENTS: Function template Class template Exception handling Try-Catch-Throw paradigm Exception specification Terminate functions Unexcepted functions Uncaught exception UNIT-III TEMPLATES AND EXCEPTION

More information

CS304 Object Oriented Programming

CS304 Object Oriented Programming 1 CS304 Object Oriented Programming 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes?

More information

PROGRAMMING IN C++ COURSE CONTENT

PROGRAMMING IN C++ COURSE CONTENT PROGRAMMING IN C++ 1 COURSE CONTENT UNIT I PRINCIPLES OF OBJECT ORIENTED PROGRAMMING 2 1.1 Procedure oriented Programming 1.2 Object oriented programming paradigm 1.3 Basic concepts of Object Oriented

More information

A First Program - Greeting.cpp

A First Program - Greeting.cpp C++ Basics A First Program - Greeting.cpp Preprocessor directives Function named main() indicates start of program // Program: Display greetings #include using namespace std; int main() { cout

More information

Reference Parameters A reference parameter is an alias for its corresponding argument in the function call. Use the ampersand (&) to indicate that

Reference Parameters A reference parameter is an alias for its corresponding argument in the function call. Use the ampersand (&) to indicate that Reference Parameters There are two ways to pass arguments to functions: pass-by-value and pass-by-reference. pass-by-value A copy of the argument s value is made and passed to the called function. Changes

More information

Cpt S 122 Data Structures. Course Review Midterm Exam # 2

Cpt S 122 Data Structures. Course Review Midterm Exam # 2 Cpt S 122 Data Structures Course Review Midterm Exam # 2 Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Midterm Exam 2 When: Monday (11/05) 12:10 pm -1pm

More information

RAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING QUESTION BANK UNIT I 2 MARKS

RAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING QUESTION BANK UNIT I 2 MARKS RAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING YEAR/SEM:II & III UNIT I 1) Give the evolution diagram of OOPS concept. 2) Give some

More information

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value Paytm Programming Sample paper: 1) A copy constructor is called a. when an object is returned by value b. when an object is passed by value as an argument c. when compiler generates a temporary object

More information

Instantiation of Template class

Instantiation of Template class Class Templates Templates are like advanced macros. They are useful for building new classes that depend on already existing user defined classes or built-in types. Example: stack of int or stack of double

More information

ADTs & Classes. An introduction

ADTs & Classes. An introduction ADTs & Classes An introduction Quick review of OOP Object: combination of: data structures (describe object attributes) functions (describe object behaviors) Class: C++ mechanism used to represent an object

More information

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2, SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN, U.O.P. UNIT-2

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2, SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN, U.O.P. UNIT-2 UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, overloading using friends, rules for operator overloading, type conversions

More information

Object Oriented Design

Object Oriented Design Object Oriented Design Chapter 6 Example Activity Diagram 1 Outline Chapter 6 Topics 6.6 C++ Standard Library Header Files 6.14 Inline Functions 6.16 Default Arguments 6.17 Unary Scope Resolution Operator

More information

Ch. 12: Operator Overloading

Ch. 12: Operator Overloading Ch. 12: Operator Overloading Operator overloading is just syntactic sugar, i.e. another way to make a function call: shift_left(42, 3); 42

More information

G52CPP C++ Programming Lecture 13

G52CPP C++ Programming Lecture 13 G52CPP C++ Programming Lecture 13 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Last lecture Function pointers Arrays of function pointers Virtual and non-virtual functions vtable and

More information

CS2141 Software Development using C/C++ C++ Basics

CS2141 Software Development using C/C++ C++ Basics CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short

More information

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor. 3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.

More information

Jayaram college of Engineering and Technology, Pagalavadi. CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT

Jayaram college of Engineering and Technology, Pagalavadi. CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT Two Mark Questions UNIT - I 1. DEFINE ENCAPSULATION. Encapsulation is the process of combining data and functions

More information

ADARSH VIDYA KENDRA NAGERCOIL COMPUTER SCIENCE. Grade: IX C++ PROGRAMMING. Department of Computer Science 1

ADARSH VIDYA KENDRA NAGERCOIL COMPUTER SCIENCE. Grade: IX C++ PROGRAMMING. Department of Computer Science 1 NAGERCOIL COMPUTER SCIENCE Grade: IX C++ PROGRAMMING 1 C++ 1. Object Oriented Programming OOP is Object Oriented Programming. It was developed to overcome the flaws of the procedural approach to programming.

More information

DELHI PUBLIC SCHOOL TAPI

DELHI PUBLIC SCHOOL TAPI Loops Chapter-1 There may be a situation, when you need to execute a block of code several number of times. In general, statements are executed sequentially: The first statement in a function is executed

More information

Objectives. In this chapter, you will:

Objectives. In this chapter, you will: Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates arithmetic expressions Learn about

More information

Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat Chapter 6 Inheritance Extending a Class

Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat Chapter 6 Inheritance Extending a Class Chapter 6 Inheritance Extending a Class Introduction; Need for Inheritance; Different form of Inheritance; Derived and Base Classes; Inheritance and Access control; Multiple Inheritance Revisited; Multilevel

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

KOM3191 Object Oriented Programming Dr Muharrem Mercimek OPERATOR OVERLOADING. KOM3191 Object-Oriented Programming

KOM3191 Object Oriented Programming Dr Muharrem Mercimek OPERATOR OVERLOADING. KOM3191 Object-Oriented Programming KOM3191 Object Oriented Programming Dr Muharrem Mercimek 1 OPERATOR OVERLOADING KOM3191 Object-Oriented Programming KOM3191 Object Oriented Programming Dr Muharrem Mercimek 2 Dynamic Memory Management

More information

Downloaded from

Downloaded from Unit I Chapter -1 PROGRAMMING IN C++ Review: C++ covered in C++ Q1. What are the limitations of Procedural Programming? Ans. Limitation of Procedural Programming Paradigm 1. Emphasis on algorithm rather

More information

UNIT 1 OVERVIEW LECTURE NOTES

UNIT 1 OVERVIEW LECTURE NOTES UNIT 1 OVERVIEW LECTURE NOTES OBJECT-ORIENTED PROGRAMMING IN C++ Object Oriented Programming is a method of visualizing and programming the problem in a global way. Object oriented programming is a technique

More information

Preface to the Second Edition Preface to the First Edition Brief Contents Introduction to C++ p. 1 A Review of Structures p.

Preface to the Second Edition Preface to the First Edition Brief Contents Introduction to C++ p. 1 A Review of Structures p. Preface to the Second Edition p. iii Preface to the First Edition p. vi Brief Contents p. ix Introduction to C++ p. 1 A Review of Structures p. 1 The Need for Structures p. 1 Creating a New Data Type Using

More information

Object-Oriented Principles and Practice / C++

Object-Oriented Principles and Practice / C++ Object-Oriented Principles and Practice / C++ Alice E. Fischer June 3, 2013 OOPP / C++ Lecture 9... 1/40 Const Qualifiers Operator Extensions Polymorphism Abstract Classes Linear Data Structure Demo Ordered

More information

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi Modern C++ for Computer Vision and Image Processing Igor Bogoslavskyi Outline Move semantics Classes Operator overloading Making your class copyable Making your class movable Rule of all or nothing Inheritance

More information

Chapter-11 POINTERS. Important 3 Marks. Introduction: Memory Utilization of Pointer: Pointer:

Chapter-11 POINTERS. Important 3 Marks. Introduction: Memory Utilization of Pointer: Pointer: Chapter-11 POINTERS Introduction: Pointers are a powerful concept in C++ and have the following advantages. i. It is possible to write efficient programs. ii. Memory is utilized properly. iii. Dynamically

More information

MaanavaN.Com CS1203 OBJECT ORIENTED PROGRAMMING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

MaanavaN.Com CS1203 OBJECT ORIENTED PROGRAMMING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING SUB CODE / SUBJECT: CS1203 / Object oriented programming YEAR / SEM: II / III QUESTION BANK UNIT I FUNDAMENTALS PART-A (2 MARKS) 1. What is Object Oriented

More information

STRUCTURING OF PROGRAM

STRUCTURING OF PROGRAM Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the

More information

Overloading Operators in C++

Overloading Operators in C++ Overloading Operators in C++ C++ allows the programmer to redefine the function of most built-in operators on a class-by-class basis the operator keyword is used to declare a function that specifies what

More information

VALLIAMMAI ENGINEERING COLLEGE

VALLIAMMAI ENGINEERING COLLEGE VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 603 203 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK B.E. - Electrical and Electronics Engineering IV SEMESTER CS6456 - OBJECT ORIENTED

More information

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions.

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions. Dr.G.R.Damodaran College of Science (Autonomous, affiliated to the Bharathiar University, recognized by the UGC)Reaccredited at the 'A' Grade Level by the NAAC and ISO 9001:2008 Certified CRISL rated 'A'

More information

DHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++

DHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++ DHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++ Objective: To Learn Basic input, output, and procedural part of C++. C++ Object-orientated programming language

More information

Quiz Start Time: 09:34 PM Time Left 82 sec(s)

Quiz Start Time: 09:34 PM Time Left 82 sec(s) Quiz Start Time: 09:34 PM Time Left 82 sec(s) Question # 1 of 10 ( Start time: 09:34:54 PM ) Total Marks: 1 While developing a program; should we think about the user interface? //handouts main reusability

More information

2 ADT Programming User-defined abstract data types

2 ADT Programming User-defined abstract data types Preview 2 ADT Programming User-defined abstract data types user-defined data types in C++: classes constructors and destructors const accessor functions, and inline functions special initialization construct

More information

Problem Solving with C++

Problem Solving with C++ GLOBAL EDITION Problem Solving with C++ NINTH EDITION Walter Savitch Kendrick Mock Ninth Edition PROBLEM SOLVING with C++ Problem Solving with C++, Global Edition Cover Title Copyright Contents Chapter

More information

Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur

Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur Operators and Expressions 8/24/2012 Dept of CS&E 2 Arithmetic operators Relational operators Logical operators

More information

CS201 Latest Solved MCQs

CS201 Latest Solved MCQs Quiz Start Time: 09:34 PM Time Left 82 sec(s) Question # 1 of 10 ( Start time: 09:34:54 PM ) Total Marks: 1 While developing a program; should we think about the user interface? //handouts main reusability

More information

Programming for Engineers Iteration

Programming for Engineers Iteration Programming for Engineers Iteration ICEN 200 Spring 2018 Prof. Dola Saha 1 Data type conversions Grade average example,-./0 class average = 23450-67 893/0298 Grade and number of students can be integers

More information

List, Stack, and Queues

List, Stack, and Queues List, Stack, and Queues R. J. Renka Department of Computer Science & Engineering University of North Texas 02/24/2010 3.1 Abstract Data Type An Abstract Data Type (ADT) is a set of objects with a set of

More information

Purpose of Review. Review some basic C++ Familiarize us with Weiss s style Introduce specific constructs useful for implementing data structures

Purpose of Review. Review some basic C++ Familiarize us with Weiss s style Introduce specific constructs useful for implementing data structures C++ Review 1 Purpose of Review Review some basic C++ Familiarize us with Weiss s style Introduce specific constructs useful for implementing data structures 2 Class The Class defines the data structure

More information

CSCE 110 PROGRAMMING FUNDAMENTALS

CSCE 110 PROGRAMMING FUNDAMENTALS CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 15. Dictionaries (1): A Key Table Class Prof. amr Goneid, AUC 1 Dictionaries(1): A Key Table Class Prof. Amr Goneid, AUC 2 A Key Table

More information

o Counter and sentinel controlled loops o Formatting output o Type casting o Top-down, stepwise refinement

o Counter and sentinel controlled loops o Formatting output o Type casting o Top-down, stepwise refinement Last Time Let s all Repeat Together 10/3/05 CS150 Introduction to Computer Science 1 1 We covered o Counter and sentinel controlled loops o Formatting output Today we will o Type casting o Top-down, stepwise

More information

MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI

MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI 621213 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Sub code: CS2203 SEM: III Sub Name: Object Oriented Programming Year: II UNIT-I PART-A 1. What is

More information

CHAPTER 3 Expressions, Functions, Output

CHAPTER 3 Expressions, Functions, Output CHAPTER 3 Expressions, Functions, Output More Data Types: Integral Number Types short, long, int (all represent integer values with no fractional part). Computer Representation of integer numbers - Number

More information

7.1 Optional Parameters

7.1 Optional Parameters Chapter 7: C++ Bells and Whistles A number of C++ features are introduced in this chapter: default parameters, const class members, and operator extensions. 7.1 Optional Parameters Purpose and Rules. Default

More information

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++ No. of Printed Pages : 3 I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination 05723. June, 2015 BCS-031 : PROGRAMMING IN C ++ Time : 3 hours Maximum Marks : 100 (Weightage 75%)

More information

Introduction to C++ Friends, Nesting, Static Members, and Templates Topic #7

Introduction to C++ Friends, Nesting, Static Members, and Templates Topic #7 Introduction to C++ Friends, Nesting, Static Members, and Templates Topic #7 CS202 7-1 Relationship of Objects Friends, Nesting Static Members Template Functions and Classes Reusing Code Template Specializations

More information

Outline. Performing Computations. Outline (cont) Expressions in C. Some Expression Formats. Types for Operands

Outline. Performing Computations. Outline (cont) Expressions in C. Some Expression Formats. Types for Operands Performing Computations C provides operators that can be applied to calculate expressions: tax is 8.5% of the total sale expression: tax = 0.085 * totalsale Need to specify what operations are legal, how

More information

Chapter 2 Basic Elements of C++

Chapter 2 Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion

More information

CSE202-Lec#4. CSE202 C++ Programming

CSE202-Lec#4. CSE202 C++ Programming CSE202-Lec#4 Functions and input/output streams @LPU CSE202 C++ Programming Outline Creating User Defined Functions Functions With Default Arguments Inline Functions @LPU CSE202 C++ Programming What is

More information

Operator Dot Wording

Operator Dot Wording 2016-10-16 Operator Dot Wording Bjarne Stroustrup (bs@ms.com) Gabriel Dos Reis (gdr@microsoft.com) Abstract This is the proposed wording for allowing a user-defined operator dot (operator.()) for specifying

More information

3. Java - Language Constructs I

3. Java - Language Constructs I Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks

More information

Kapi ap l S e S hgal P T C p t u er. r S. c S ienc n e A n A k n leshw h ar ar Guj u arat C C h - 8

Kapi ap l S e S hgal P T C p t u er. r S. c S ienc n e A n A k n leshw h ar ar Guj u arat C C h - 8 Chapter 8 Introduction C++ Memory Map Free Stores Declaration and Initialization of pointers Dynamic allocation operators Pointers and Arrays Pointers and Const Pointers and Function Pointer and Structures

More information

Variables. Data Types.

Variables. Data Types. Variables. Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable. We had to write several lines of code, compile them, and then execute the resulting

More information

JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli (An approved by AICTE and Affiliated to Anna University)

JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli (An approved by AICTE and Affiliated to Anna University) Estd: 1994 JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli - 621014 (An approved by AICTE and Affiliated to Anna University) ISO 9001:2000 Certified Subject Code & Name : CS 1202

More information