Chapter 9. Operator Overloading. Dr Ahmed Rafat

Size: px
Start display at page:

Download "Chapter 9. Operator Overloading. Dr Ahmed Rafat"

Transcription

1 Chapter 9 Operator Overloading

2 Overloading Operators Overloading Basics How Operators are Overloaded Arithmetic Operators Fstring Class Example Cast Operator Equality and Relational Operators

3 Bitwise Operators Shifting Bits Bitwise AND Bitwise OR Bitwise Exclusive OR Bitwise NOT BitArray Class Example

4 How Operators are Overloaded

5 Operator Overloading: Refers to the technique of ascribing new meaning to standard operators, such as +, >>, and = when used with class operands. Operator Function: Is a function whose name consists of the keyword operator. Home

6 Unary Operator: Is an operator that has only a single operand. Example : ++ increment -- decrement ( ) function call [ ] subscript + plus - minus! Logical Not

7 Binary Operator: Is an operator that has two operands. Example : + Addition - Subtraction * Multiplication / Division % Modulus = Assignment += additional with assignment -= subtraction with assignment *= multiplication with assignment /= division with assignment %= modulus with assignment

8 Binary Operator cont. & bitwise AND bitwise OR ^ bitwise exclusive OR logical OR && logical AND == equal!= not equal > greater than < less than >= greater than or equal <= less than or equal << left shift <<= left shift with assignment >> right shift >>= right shift with assignment

9 Operator function must be either a non-static member function or a non-member function having at least one parameter, whose type is a class, reference to a class, enumeration, or reference to an enumeration. For example // Invalid Code int operator + ( int x, int y) return x+y; }

10 // valid because at least one parameter is a class type class Integer. public: int value; }; int operator = (const Integer & x, int y) return x.value+y; }

11 Arithmetic Operators

12 We define a class called Time that perform range checking and operations on time values. The Time class prevents users from assigning illegal values to hours and minutes, and provides a convenient way for incrementing the minutes in an hour.

13 Implementing the prefix ++ operator Prefix operator : returns the time value after it was incremented. We add 1 to the minutes and check to see if they have 59 If so, we increment the hour. If the hour exceeds 23, we roll it over to zero with the modulus % operator. const Time & Time::operator ++( ) if ( ++minutes > MinuteMax ) minutes = 0; hours = ( hours + 1 ) % ( HoursMax + 1 ); } return *this; }

14 Implementing the postfix ++ operator Postfix operator: returns the time value before it was incremented. We have to save the current Time, call the prefix ++ operator, and return the saved Time. Time Time::operator ++ ( int ) Time save ( *this ); operator ++ ( ); return save; } // Copy Constructor // Increment the time // Return the copy

15 Implementing the += operator Time class has an addition-assignment operator that add n minutes to the current time. After adding n to the minutes, we check for possible overflow by using modulus and integer division. const Time & Time::operator += ( unsigned n ) unsigned t = minutes + n; minutes = t % ( MinuteMax + 1); // Remaining Minutes hours += t / ( MinuteMax + 1 ); // Add to hours hours = hours % ( HoursMax + 1); // Roll over to next day return *this; }

16 Example If current time were 12:50 and we added 25 minutes t would become ( 50+25=75). minutes would become 15 ( t mod 60 ) and hours would become 13 ( 12+= t/60)

17 Test the Time class We create several Time objects, initialize them with variety of values, increment them, and display their new values. } void Test ( ) Time a; Time b (1845); cout<<++a<< \n // 00:01 <<b++<<endl; // 18:45 Time c (2359); cout<<( c += 15)<< \n ; // 00:14 Time d (1230); for (unsigned i=0; i<50; i++) cout<<++d<<, <<endl; cout<<endl;

18 Notice that : Time a is incremented before it is written to the output stream; Time b is written to the stream before being incremented. // Main function int main( ) try test( ); // Test the time class } catch ( const RangeError & R ) cout<<r; } return 0; }

19 Output

20 Fstring Class Example

21 Copy Constructor The following two statements both call the copy constructor Fstring s2(s1); Fstring s2=s1; Second statement doesn t call operator = Assignment Operator The following statement calls operator = s2=s1; Operator = returns a reference to the current Fstring, allowing it to be used in nested expression such as S1=S2= Filemore ; If the function returns an Fstring object ( rather than a reference ), the function would have to construct a temporary Fstring and return a copy of the current Fstring object. This would waste processing time and memory.

22 Implementing the += operator Fstring class has an addition-assignment operator that attaches another string to the end of the current one Fstring & Fstring::operator +=( const Fstring & s) size_t n=strlen( str ) + strlen (s.str); if(n>= MaxSize) throw RangeError( FILE, LINE,n); strcat ( str, s.str); return *this; } We have improved it here by having it throw a RangeError exception. If the combined length of the two strings exceeds MaxSize.

23 Implementing the Assignment operator The = operator, used for assigning a new string to the current one. First implementation assigns the Fstring parameter to the current string, making sure that the current string and d are not the same object. Fstring & Fstring::operator = (const Fstring & s) if ( *this ==s ) // can t assign object to itself return *this; size_t n= strlen (s.str); if ( n>maxsize ) throw RangeError ( FILE, LINE,n); strcpy ( str, s.str ); return *this; }

24 Second implementation converts const char* parameter to an Fstring and calls the first operator = function Fstring & Fstring::operator = ( const char *s ) return *this = Fstring (s); } Third implementation stores the character parameter in the first position of the string and appends NULL byte Fstring & Fstring::operator = ( char ch ) str [0] = ch; str [1] = \0 ; return *this; }

25 Cast Operator Cast operator is useful for performing conversion between a class object and some other types. Example : We might want to provide way of converting an Fstring object containing a string of digits into long. Fstring class would include the following declaration of member function that cast into long class Fstring public : operator long ( ) const; //. };

26 The declaration syntax is unusual in that it doesn t show a return type, the return type is understand to be the target type of the cast, in this case, long. #include<stdlib.h> Fstring::operator long ( ) const return strtol (str,0,0); } Cast operator can also use a pointer as its target type. For Example : we might need to convert an Fstring object to char * in order to pass it to function. class Fstring public: operator const char * ( ) const; //. }; Fstring::operator const char * ( ) const return str; }

27 There can t be an implicit conversion from a new type to an existing type unless we purse one of two alternatives : First alternative : involves changing the interface of an existing class, which can cause for reaching changes to user code. Second alternative : adding a cast operator to the new class, is preferable because it affects only the new class.

28 Equality and Relational operators

29 When it is reasonable to compare two instances of the same class, it is a good idea to overload the equality ( == and!= ) and relational (>,<,<=,>+) operators. For example : we declare two operands that compare student objects by their ID numbers. class Student public : int operator == ( const Student & s ) const ; int operator < ( const Student & s) const ; private : long id ; }; int Student::operator == (const Student & s) const return id == s.id ; } int Student::operator < ( const Student & s ) const return id < s.id ; }

30 Non-Member operator Functions The stream output operator, for example, is customarily placed at the right of a stream object or reference to a stream object, and at the left of expression being written to the stream: point p; cout<<p; But this order of operands would not be possible if the operator << function were a class member. This is what declaration would look like : class Point public: ostream & operator << ( ostream & os ); //. };

31 Point object would have to invoke the operator function, or point would have to appear as left-hand operand in a binary expression. point p; p.operator << ( cout ); p<<cout; // Function call // Same effect To declare this operator as non-member function, in which first argument is stream and second id point. This allows the operands to appear in the normal order with the stream at the left and point at the right. point p; cout<<p; ostream & operator <<( ostream & os, Const point & p ) os<<p.getx( )<<, <<p.gety( ); return os; } If the function required direct access to the private point data members, we could declare it as a friend of the point class.

32 Output

33 Bitwise Operators

34 We will introduce a class called BitArray that makes extensive use of bitwise operators.we assume that all values are unsigned. Using unsigned integers n and j. Quick summary of the operator n << j n is shifted j bits to the left n >> j n is shifted j bits to right n & j n is ANDed with j n j n is ORed with j n ^ j n is exclusive ORed with j ~ n n is NOTed

35 Shifting Bits

36 The shift operator moves all bits in an operand either lift or right. For example, n is type unsigned char and represented by eight bits. As n is shift to the lift. The highest bit disappears,each of the other bits moves one position to the left,and the lowest bit position is cleared(set to 0): n = unsigned char n; n=0xcf; n = n << 1; n= When n is shifted to the right, the lowest bit disappers,other bits are moved to the right, and the highest position is cleared unsigned char n; n = n=0xcf; n=n>>1; n =

37 Bitwise AND

38 When two bitwise ANDed together, each bit in the first is matched to its corresponding bit in the second.the resulting bit is 1 only if the two input bits were1.for unsigned character values n and j. n= j= n & j =

39 Bitwise OR

40 When two bitwise ORed together, each bit in the same position of the numbers is matched up.the resulting bit is always 1 unless both of the input bits were 0.For unsigned character values n and j. n = j = n j =

41 Bitwise Exclusive OR

42 When two bitwise exclusive ORed together, each bit in the numbers are matched up.the resulting bit is 1 only if two input bits were different.for unsigned character values n and j. n = j = n ^ j = The exclusive OR can be used to reverse,or toggle the bits in a number. This is done by excluvise ORing a number with all 1 s : n = j = n ^ j =

43 Bitwise NOT

44 The bit wise NOT operator also toggles all bits a number: n = ~n =

45 BitArray Class Example

46 No data type exist to store unlimited number of bits. The maximum number of bit is 64 (Long) Q What if we want to store 128 bit? Solution: What data type can be used?! Encapsulate data about bits in a class called BitArray

47 BitArray Class Definition Specify the size of the array at runtime Allocate a dynamic memory for the array storing the bits The class includes a default constructor, that lets the caller determine the array size, a destructor, assignment operator, set union operator( =), set intersection operator(&=) as will << and >> stream I/o operator The Reset function : clear one or all bits The set function : set one or all bits The Test function : checks a single bit to see if it has been set Toggle function : reverses a single bit

48 Anatomy BitArray Fields: 1) Bits: is an array of int each int is capable to store 32 bit or 16 bit. so 128 bits will use 3 cell 2) NumElements: to count how many cells of bits used to store the binary number. 3) Size: used to store number of bits.

49 bits Array of int 32 bit numelements = 5 cells Each cell has 32 bit Number of total bits = 32*5

50 BitArray bits Size : # of bits numelements : # of cells Set ( # of bit ) Reset ( # of bit ) Toggle ( # of bit) Test ( # of bit )

51 Set (int n) X bits OR mask 1 1 << ( n % 32 ) Bits [ n/numbits ] = ( (eletype ) 1 << n % numbits )

52 Reset ( int n ) X bits & AND mask ~ (1<< n % 32 ) Bits [ n/numbits ] & = ~ ) ( eletype ) 1 << n % numbits ) Reset () for ( int i=0; i< numelements; i++ ) bits [ i ] = 0 ;

53 Toggle (int n) X bits ^ mask ~X Bits [ n/numbits ] ^ = ~ (( eletype ) 1 << n % numbits ) Toggle ( ) for ( int i=0; i< numelements ; i++ ) bits [ i ] =~ bits [ i ] ;

54 Test (int n ) X ? bits & mask 0 Nonzero 0 1 int z = Bits [ n/numbits ] & (( eletype ) 1 << n % numbits )

55 BitArray class Example class BitArray private: enum BitPerByte = 8, NumBits = SizeOf(elttype)*BitPerByte} ; size_t size; // maximum number of bits size_t numelements; // size of bits [ ] array elttype * bits; // array of bits } ;

56 Each array component is of type elttype, which we currently define as unsigned int. BitsPerByte determines the number of bits that may be stored in a single byte. NumBits counts the total number of bit positions in each array component, based on the number of bytes in a component, and BitPerByte. Notice that size_t is used throughout the class; this is a standard synonym for unsigned int type.

57 Constructor Bit array constructor has parameter that specifies the number of bit positions in the array. We subtract 1 from this number, divide by NumBits and add 1 to determine the reguired number of array components. BitArray :: BitArray (size_t sz) size = sz ; numelements = ( (size 1) / NumBits) +1 ; bits = new elttype [ numelements] ; Reset ( ) ; }

58 Count Function The count function tests each bit position and return the number of bits that are set. size_t BitArray :: count ( ) const size_t tally =0 ; for ( size_t i=0; i<size; i++) if ( Test (i) ) tally ++ ; } return tally ; }

59 Calculating Bit Offset Suppose that we want to implement the Test member function, which return 1 if a particlar bit has been set. The array of integers holding the bits is called bits. Let s assume that NumBits equals 8 and we want to locate and test bit n. First we devide n by NumBits to get the array index ( subscript) j that indicate which array element is to be examined un signed j = n / NumBits ;

60 Next we isolate the correct bit by constructing a mask. The expression n % NumBits tells us how many positions to shift 1 to the left align with n s bit position within the current array component. Elttype mask = ( elttype ) 1 << ( n% NumBits ) Next we AND bits [ j ] with the mask and return 1 if the resulting value is not 0. int Z= bits [ j ] & mask return Z!=0

61 Example : Suppose that the array contained the following values and we wanted to check bit 17 : The bits [ ] array NumBits = 8 n = 17 [ 2 ] [ 1 ] [ 0 ] bit 17 J = 17 / 8 = [ 2 ] Mask = 1 << (17 % 8) = 1 << 1 = mask

62 Z = bits [ 2 ] & 2 = 2 // answer : bit 17 is set &

63 Test function The foregoing steps can be folded into a single expression that isolate bit n, and return with its value. int BitArray :: Test ( size_t n) const if ( n>= size ) throw RangeError ( FILE, LINE, n); int z = bits [ n / NumBits ] & ( ( elttype ) 1 << n% NumBits ) ; return Z! =0 ; }

64 Toggle function The toggle function reverses a single bit at position n by XORing it with 1 : void BitArray :: Toggle ( size_t n ) if ( n>= size ) throw RangeError ( FILE, LINE, n); bits [ n / NumBits ] ^ = ( (elttype) 1 << n % NumBits); }

65 Set function The set function sets a single bit at position n void BitArray :: set ( size_t n) if ( n >= size ) throw RangeError ( FILE, LINE, n) ; bits [ n / NumBits ] 1 = ( ( elttype ) 1 << n%numbits) ; }

66 Union operation The = operator is useful for computing the union of two sets. The = operator performs a bitwise OR of each bit in the current array with another array called B2. BitArray & BitArray :: operator = ( const BitArray & B2 ) size count = min ( numelements, B2.numElements ); for ( size_t i=0; i<count ; i++ ) bits [ I ] 1= B2.bits [ I ] ; return *this ; } The min function return the smaller of two unsigned integers.

67 Intersection operation The &= operator is useful computing the intersection two sets. The &= operator performs a bitwise AND of each bit in the current array with another array. BitArray & BitArray :: operator &= ( const BitArray & B2 ) size_t count = min ( numelements, B2.numElements); for ( size_t i=0 ; i< count ; i++ ) bits [ I ] &= B2.bits [ I ] ; return *this; }

68 Stream output operator The stream output operator incorporates the Test operation into translating the bit array with a string of 1 and 0 characters. ostream & operator << ( ostream &os, const BitArray & BA ) for ( size_t i= BA.size ; 0< I ; i++) os<< ( BA.Test (--i)? 1 : 0 ); return os; }

69 Test the BitArray class Main calls several test function, enclosing the calls in a try block. This permits the program to catch the two types of exceptions that can be thrown. int main ( ) try Test1 ( ); Test2 ( ); Test3 ( ); Test4 ( ); } catch ( const RangeError & re ) cout << re ; } catch ( const NoFileError & nf ) cout << nf ; } return 0 ; }

70 void Test1 ( ) Test 1 // Assign along integer to a BitArray object and display the bits. BitArray X(20); X=( ) ; cout << X << \n ; } // Set and reset bit 12 in Bitarray X X.Set (12 ) ; cout<< X << \n ; X.Reset ( 12 ); cout << X << \n ;

71 Test 2 void Test2 ( ) // Read a string of bits from file. ifstream bfile ( bits.txt ); if(! bfile ) throw NoFileError ( bfile ); bfile >> filebits ; cout << filebits << \n ; }

72 Test 3 void Test3 ( ) // Add several integers to a set const size_t setsize = 16 ; BitArray B (SetSize) ; B.Set (1); // Add several elements B.Set (5); B.set (8); B.Set (15); cout<< \n ; << BitArray B: << B << \ n ;

73 // Test for set membership for ( int i=0; i< SetSize ; i++ ) if ( B.Test (1) ) cout<< Setw(2) << I << is a member << \n ; // Perform union and intersection operations BitArray A ( SetSize ); A.Set (3); A.Set (4); A.Set (9); cout<< \n BitArray B : << B ; cout<< \n BitArray A : << A ; A!=B; cout<< \n A union B: << A ; A.Toggle (4); cout << \n Toggled bit 4 : << A << \n ;

74 Test 4 Simulates the scheduling of collage classrooms. We create an array called rooms, and set individual bits matching room that happen to be available. void Test4 ( ) // Create a room scheduling application, and determine which room // are both requested and available. enum -101,-110,-112,-114,-120,-190,-192,200,-201,-205,-208, - 210,-220,-221,-225,-230 } const size_t RoomMax =16 ; BitArray rooms ( RoomMatrix );

75 rooms.set(-101); rooms.set(-110); rooms.set(-120); rooms.set(-220); rooms.set(-221); rooms.set(-225); cout<< \n rooms: <<rooms; // Requests represents requests for available rooms that could be // used for college courses. BitArray reguests (RoomMax); requests.set(-101); requests.set(-110); requests.set(-120); requests.set(-225); requests.set(-230); cout<< \n requests: <<requests;

76 } BitArray approved (RoomMax); approved 1= request ; // Union approved &= rooms ; // Intersection cout<< \n requests approved : << approved << endl;

77 Output

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

A flow chart is a graphical or symbolic representation of a process.

A flow chart is a graphical or symbolic representation of a process. Q1. Define Algorithm with example? Answer:- A sequential solution of any program that written in human language, called algorithm. Algorithm is first step of the solution process, after the analysis of

More information

GO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one.

GO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one. http://www.tutorialspoint.com/go/go_operators.htm GO - OPERATORS Copyright tutorialspoint.com An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.

More information

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java - Basic Operators Java provides a rich set of operators to manipulate variables.

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

JAVA OPERATORS GENERAL

JAVA OPERATORS GENERAL JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators

More information

Programming in C++ 5. Integral data types

Programming in C++ 5. Integral data types Programming in C++ 5. Integral data types! Introduction! Type int! Integer multiplication & division! Increment & decrement operators! Associativity & precedence of operators! Some common operators! Long

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

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

The Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and

The Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and The Arithmetic Operators The arithmetic operators refer to the standard mathematical operators: addition, subtraction, multiplication, division and modulus. Op. Use Description + x + y adds x and y x y

More information

The Arithmetic Operators

The Arithmetic Operators The Arithmetic Operators The arithmetic operators refer to the standard mathematical operators: addition, subtraction, multiplication, division and modulus. Examples: Op. Use Description + x + y adds x

More information

Expressions and Precedence. Last updated 12/10/18

Expressions and Precedence. Last updated 12/10/18 Expressions and Precedence Last updated 12/10/18 Expression: Sequence of Operators and Operands that reduce to a single value Simple and Complex Expressions Subject to Precedence and Associativity Six

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

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

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

CSC 1214: Object-Oriented Programming

CSC 1214: Object-Oriented Programming CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:

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

Information Science 1

Information Science 1 Information Science 1 Simple Calcula,ons Week 09 College of Information Science and Engineering Ritsumeikan University Topics covered l Terms and concepts from Week 8 l Simple calculations Documenting

More information

Engineering Computing I

Engineering Computing I Engineering Computing I Types, Operators, and Expressions Types Operators Expressions 2 1 2.1 Variable Names Names are made up of letters and digits The first character must be a letter The underscore

More information

Chapter 3: Operators, Expressions and Type Conversion

Chapter 3: Operators, Expressions and Type Conversion 101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To

More information

Operators and Expressions:

Operators and Expressions: Operators and Expressions: Operators and expression using numeric and relational operators, mixed operands, type conversion, logical operators, bit operations, assignment operator, operator precedence

More information

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING Unit I : OVERVIEW PART A (2 Marks) 1. Give some characteristics of procedure-oriented

More information

SECTION II: LANGUAGE BASICS

SECTION II: LANGUAGE BASICS Chapter 5 SECTION II: LANGUAGE BASICS Operators Chapter 04: Basic Fundamentals demonstrated declaring and initializing variables. This chapter depicts how to do something with them, using operators. Operators

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

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

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

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

CprE 288 Introduction to Embedded Systems Exam 1 Review.  1 CprE 288 Introduction to Embedded Systems Exam 1 Review http://class.ece.iastate.edu/cpre288 1 Overview of Today s Lecture Announcements Exam 1 Review http://class.ece.iastate.edu/cpre288 2 Announcements

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

Operators. Java operators are classified into three categories:

Operators. Java operators are classified into three categories: Operators Operators are symbols that perform arithmetic and logical operations on operands and provide a meaningful result. Operands are data values (variables or constants) which are involved in operations.

More information

Operators & Expressions

Operators & Expressions Operators & Expressions Operator An operator is a symbol used to indicate a specific operation on variables in a program. Example : symbol + is an add operator that adds two data items called operands.

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

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

Program construction in C++ for Scientific Computing

Program construction in C++ for Scientific Computing 1 (26) School of Engineering Sciences Program construction in C++ for Scientific Computing 2 (26) Outline 1 2 3 4 5 6 3 (26) Our Point class is a model for the vector space R 2. In this space, operations

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

Expressions. Arithmetic expressions. Logical expressions. Assignment expression. n Variables and constants linked with operators

Expressions. Arithmetic expressions. Logical expressions. Assignment expression. n Variables and constants linked with operators Expressions 1 Expressions n Variables and constants linked with operators Arithmetic expressions n Uses arithmetic operators n Can evaluate to any value Logical expressions n Uses relational and logical

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

Operators and Expressions

Operators and Expressions Operators and Expressions Conversions. Widening and Narrowing Primitive Conversions Widening and Narrowing Reference Conversions Conversions up the type hierarchy are called widening reference conversions

More information

Arithmetic Operators. Portability: Printing Numbers

Arithmetic Operators. Portability: Printing Numbers Arithmetic Operators Normal binary arithmetic operators: + - * / Modulus or remainder operator: % x%y is the remainder when x is divided by y well defined only when x > 0 and y > 0 Unary operators: - +

More information

Operators in C. Staff Incharge: S.Sasirekha

Operators in C. Staff Incharge: S.Sasirekha Operators in C Staff Incharge: S.Sasirekha Operators An operator is a symbol which helps the user to command the computer to do a certain mathematical or logical manipulations. Operators are used in C

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

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

KOM3191 Object Oriented Programming Dr Muharrem Mercimek ARRAYS ~ VECTORS. KOM3191 Object-Oriented Computer Programming

KOM3191 Object Oriented Programming Dr Muharrem Mercimek ARRAYS ~ VECTORS. KOM3191 Object-Oriented Computer Programming KOM3191 Object Oriented Programming Dr Muharrem Mercimek 1 ARRAYS ~ VECTORS KOM3191 Object-Oriented Computer Programming KOM3191 Object Oriented Programming Dr Muharrem Mercimek 2 What is an array? Arrays

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

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

CSC 330 Object Oriented Programming. Operator Overloading Friend Functions & Forms

CSC 330 Object Oriented Programming. Operator Overloading Friend Functions & Forms CSC 330 Object Oriented Programming Operator Overloading Friend Functions & Forms 1 Restrictions on Operator Overloading Most of C++ s operators can be overloaded. Operators that can be overloaded + -

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

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

Unit 3. Operators. School of Science and Technology INTRODUCTION

Unit 3. Operators. School of Science and Technology INTRODUCTION INTRODUCTION Operators Unit 3 In the previous units (unit 1 and 2) you have learned about the basics of computer programming, different data types, constants, keywords and basic structure of a C program.

More information

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators Course Name: Advanced Java Lecture 2 Topics to be covered Variables Operators Variables -Introduction A variables can be considered as a name given to the location in memory where values are stored. One

More information

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Basic Operators Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators

More information

Department of Computer Science

Department of Computer Science Department of Computer Science Definition An operator is a symbol (+,-,*,/) that directs the computer to perform certain mathematical or logical manipulations and is usually used to manipulate data and

More information

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands Introduction Operators are the symbols which operates on value or a variable. It tells the compiler to perform certain mathematical or logical manipulations. Can be of following categories: Unary requires

More information

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites: C Programming Code: MBD101 Duration: 10 Hours Prerequisites: You are a computer science Professional/ graduate student You can execute Linux/UNIX commands You know how to use a text-editing tool You should

More information

Introduction to Computer Science Midterm 3 Fall, Points

Introduction to Computer Science Midterm 3 Fall, Points Introduction to Computer Science Fall, 2001 100 Points Notes 1. Tear off this sheet and use it to keep your answers covered at all times. 2. Turn the exam over and write your name next to the staple. Do

More information

ISA 563 : Fundamentals of Systems Programming

ISA 563 : Fundamentals of Systems Programming ISA 563 : Fundamentals of Systems Programming Variables, Primitive Types, Operators, and Expressions September 4 th 2008 Outline Define Expressions Discuss how to represent data in a program variable name

More information

Chapter 7. Additional Control Structures

Chapter 7. Additional Control Structures Chapter 7 Additional Control Structures 1 Chapter 7 Topics Switch Statement for Multi-Way Branching Do-While Statement for Looping For Statement for Looping Using break and continue Statements 2 Chapter

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

DEPARTMENT OF MATHS, MJ COLLEGE

DEPARTMENT OF MATHS, MJ COLLEGE T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,

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

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are: LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words

More information

Chapter-8 DATA TYPES. Introduction. Variable:

Chapter-8 DATA TYPES. Introduction. Variable: Chapter-8 DATA TYPES Introduction To understand any programming languages we need to first understand the elementary concepts which form the building block of that program. The basic building blocks include

More information

Infix to Postfix Conversion

Infix to Postfix Conversion Infix to Postfix Conversion Infix to Postfix Conversion Stacks are widely used in the design and implementation of compilers. For example, they are used to convert arithmetic expressions from infix notation

More information

nptr = new int; // assigns valid address_of_int value to nptr std::cin >> n; // assigns valid int value to n

nptr = new int; // assigns valid address_of_int value to nptr std::cin >> n; // assigns valid int value to n Static and Dynamic Memory Allocation In this chapter we review the concepts of array and pointer and the use of the bracket operator for both arrays and pointers. We also review (or introduce) pointer

More information

Chapter 3. Numeric Types, Expressions, and Output

Chapter 3. Numeric Types, Expressions, and Output Chapter 3 Numeric Types, Expressions, and Output 1 Chapter 3 Topics Constants of Type int and float Evaluating Arithmetic Expressions Implicit Type Coercion and Explicit Type Conversion Calling a Value-Returning

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

Object Oriented Programming. Solved MCQs - Part 2

Object Oriented Programming. Solved MCQs - Part 2 Object Oriented Programming Solved MCQs - Part 2 Object Oriented Programming Solved MCQs - Part 2 It is possible to declare as a friend A member function A global function A class All of the above What

More information

C Programming Multiple. Choice

C Programming Multiple. Choice C Programming Multiple Choice Questions 1.) Developer of C language is. a.) Dennis Richie c.) Bill Gates b.) Ken Thompson d.) Peter Norton 2.) C language developed in. a.) 1970 c.) 1976 b.) 1972 d.) 1980

More information

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010 CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011 Lectures 1-22 Moaaz Siddiq Asad Ali Latest Mcqs MIDTERM EXAMINATION Spring 2010 Question No: 1 ( Marks: 1 ) - Please

More information

UNIT 3 OPERATORS. [Marks- 12]

UNIT 3 OPERATORS. [Marks- 12] 1 UNIT 3 OPERATORS [Marks- 12] SYLLABUS 2 INTRODUCTION C supports a rich set of operators such as +, -, *,,

More information

Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators

Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators Operators Overview Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators Operands and Operators Mathematical or logical relationships

More information

Data Types and Variables in C language

Data Types and Variables in C language Data Types and Variables in C language Disclaimer The slides are prepared from various sources. The purpose of the slides is for academic use only Operators in C C supports a rich set of operators. Operators

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

Informatics Ingeniería en Electrónica y Automática Industrial

Informatics Ingeniería en Electrónica y Automática Industrial Informatics Ingeniería en Electrónica y Automática Industrial Operators and expressions in C Operators and expressions in C Numerical expressions and operators Arithmetical operators Relational and logical

More information

Java Primer 1: Types, Classes and Operators

Java Primer 1: Types, Classes and Operators Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types,

More information

UNIT-2 Introduction to C++

UNIT-2 Introduction to C++ UNIT-2 Introduction to C++ C++ CHARACTER SET Character set is asset of valid characters that a language can recognize. A character can represents any letter, digit, or any other sign. Following are some

More information

Overloaded Operators, Functions, and Students

Overloaded Operators, Functions, and Students , Functions, and Students Division of Mathematics and Computer Science Maryville College Outline Overloading Symbols 1 Overloading Symbols 2 3 Symbol Overloading Overloading Symbols A symbol is overloaded

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 Volume II OBJECT TECHNOLOGY OBJECTIVE QUESTIONS R.Sreenivasan SanThome HSS, Chennai-4. Chapter -1

+2 Volume II OBJECT TECHNOLOGY OBJECTIVE QUESTIONS R.Sreenivasan SanThome HSS, Chennai-4. Chapter -1 Chapter -1 1. Object Oriented programming is a way of problem solving by combining data and operation 2.The group of data and operation are termed as object. 3.An object is a group of related function

More information

C-LANGUAGE CURRICULAM

C-LANGUAGE CURRICULAM C-LANGUAGE CURRICULAM Duration: 2 Months. 1. Introducing C 1.1 History of C Origin Standardization C-Based Languages 1.2 Strengths and Weaknesses Of C Strengths Weaknesses Effective Use of C 2. C Fundamentals

More information

A complex expression to evaluate we need to reduce it to a series of simple expressions. E.g * 7 =>2+ 35 => 37. E.g.

A complex expression to evaluate we need to reduce it to a series of simple expressions. E.g * 7 =>2+ 35 => 37. E.g. 1.3a Expressions Expressions An Expression is a sequence of operands and operators that reduces to a single value. An operator is a syntactical token that requires an action be taken An operand is an object

More information

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this

More information

XC Specification. 1 Lexical Conventions. 1.1 Tokens. The specification given in this document describes version 1.0 of XC.

XC Specification. 1 Lexical Conventions. 1.1 Tokens. The specification given in this document describes version 1.0 of XC. XC Specification IN THIS DOCUMENT Lexical Conventions Syntax Notation Meaning of Identifiers Objects and Lvalues Conversions Expressions Declarations Statements External Declarations Scope and Linkage

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

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

BASIC ELEMENTS OF A COMPUTER PROGRAM

BASIC ELEMENTS OF A COMPUTER PROGRAM BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators

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

.Net Technologies. Components of.net Framework

.Net Technologies. Components of.net Framework .Net Technologies Components of.net Framework There are many articles are available in the web on this topic; I just want to add one more article over the web by explaining Components of.net Framework.

More information

Review of the C Programming Language for Principles of Operating Systems

Review of the C Programming Language for Principles of Operating Systems Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights

More information

Bits and Bytes. Bit Operators in C/C++

Bits and Bytes. Bit Operators in C/C++ Bits and Bytes The byte is generally the smallest item of storage that is directly accessible in modern computers, and symbiotically the byte is the smallest item of storage used by modern programming

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

ME 461 C review Session Fall 2009 S. Keres

ME 461 C review Session Fall 2009 S. Keres ME 461 C review Session Fall 2009 S. Keres DISCLAIMER: These notes are in no way intended to be a complete reference for the C programming material you will need for the class. They are intended to help

More information

Interview Questions of C++

Interview Questions of C++ Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.

More information

Model Viva Questions for Programming in C lab

Model Viva Questions for Programming in C lab Model Viva Questions for Programming in C lab Title of the Practical: Assignment to prepare general algorithms and flow chart. Q1: What is a flowchart? A1: A flowchart is a diagram that shows a continuous

More information

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW IMPORTANT QUESTIONS IN C FOR THE INTERVIEW 1. What is a header file? Header file is a simple text file which contains prototypes of all in-built functions, predefined variables and symbolic constants.

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

Operators. Lecture 12 Section Robb T. Koether. Hampden-Sydney College. Fri, Feb 9, 2018

Operators. Lecture 12 Section Robb T. Koether. Hampden-Sydney College. Fri, Feb 9, 2018 Operators Lecture 12 Section 14.5 Robb T. Koether Hampden-Sydney College Fri, Feb 9, 2018 Robb T. Koether (Hampden-Sydney College) Operators Fri, Feb 9, 2018 1 / 21 Outline 1 Operators as Functions 2 Operator

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

Lesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University

Lesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University Lesson #3 Variables, Operators, and Expressions Variables We already know the three main types of variables in C: int, char, and double. There is also the float type which is similar to double with only

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information