lecture-14 - 40 Converting between Types • Cast operator...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
40 Object Oriented Programming C++ Operator Overloading R.B. Lenin Winter 2006 DA-IICT Converting between Types • Cast operator – Convert objects into built-in types or other objects – Conversion operator must be a non- static member function. – Cannot be a friend function – Do not specify return type For user-defined class A A::operator char *() const; // A to char A::operator int() const; //A to int A::operator otherClass() const; //A to otherClass – When compiler sees (char *) s it calls s.operator char*()
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
41 Object Oriented Programming C++ Operator Overloading R.B. Lenin Winter 2006 DA-IICT
Background image of page 2
42 Object Oriented Programming C++ Operator Overloading R.B. Lenin Winter 2006 DA-IICT Output: 6 112
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
43 Object Oriented Programming C++ Operator Overloading R.B. Lenin Winter 2006 DA-IICT
Background image of page 4
44 Object Oriented Programming C++ Operator Overloading R.B. Lenin Winter 2006 DA-IICT Output: Here is string: This is a test Here is copy of string: This is a test
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
45 Object Oriented Programming C++ Operator Overloading
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/15/2010 for the course CSE IT325 taught by Professor Maniklaldas during the Spring '09 term at Punjab Engineering College.

Page1 / 14

lecture-14 - 40 Converting between Types • Cast operator...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online