L10 - CSci 1113 C/C for Scientists and Engineers Section 010 evening class Operator Overloading friend functions Prof Eric Van Wyk and Ted Kaminski

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

View Full Document Right Arrow Icon
: CSci 1113 C/C++ for Scientists and Engineers Section 010 - evening class Operator Overloading, friend functions Prof. Eric Van Wyk and Ted Kaminski Spring 2010 c ± Van Wyk and Kaminski CSci 1113: C/C++ for Scientists and Engineers, evening class Spring 2010 Page 1 / 25
Background image of page 1

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

View Full DocumentRight Arrow Icon
: Agenda I developing a complex number class I separate compilation I operator overloading I friend modifier I Read Chapter 8 of Savitch. I Lab midterm next week. Be sure to get all the code you’ve written with your lab partner. Look for some review notes online. c ± Van Wyk and Kaminski CSci 1113: C/C++ for Scientists and Engineers, evening class Spring 2010 Page 2 / 25
Background image of page 2
: Complex numbers I We develop a Complex class for representing complex numbers. I It supports the addition, multiplication, equality checking and output of complex numbers. I It will eventually support the operations + , * , == , and << . c ± Van Wyk and Kaminski CSci 1113: C/C++ for Scientists and Engineers, evening class Spring 2010 Page 3 / 25
Background image of page 3

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

View Full DocumentRight Arrow Icon
: string streams I String streams support the same operators << and >> as cout and cin and the file streams. I But they store output in (or read from) a string. I On output streams, the str methods extracts the string. c ± Van Wyk and Kaminski CSci 1113: C/C++ for Scientists and Engineers, evening class Spring 2010 Page 4 / 25
Background image of page 4
: Review I No default constructor. I Introduction of stringstreams I const methods I This code is in ComplexIntro.cpp . c ± Van Wyk and Kaminski CSci 1113: C/C++ for Scientists and Engineers, evening class Spring 2010 Page 5 / 25
Background image of page 5

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

View Full DocumentRight Arrow Icon
: Separate compilation I Developing Complex in the same file as main means that we can’t use Complex in another program. I Separate compilation lets us pull the apart and put the Complex class in different files from the ones that use them. I We put the class definition in a .h file. I We put the implementation in a .cpp file. I We put the users of Complex in another .cpp file. I We get files: Complex.h , Complex.cpp , and ComplexDemo.cpp .
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 10/28/2010 for the course CSCI 1113 taught by Professor Staff during the Spring '08 term at Minnesota.

Page1 / 27

L10 - CSci 1113 C/C for Scientists and Engineers Section 010 evening class Operator Overloading friend functions Prof Eric Van Wyk and Ted Kaminski

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