eecs280.discussion.week13

eecs280.discussion.week13 - MultiplyN::MultiplyN(int n) {...

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

View Full Document Right Arrow Icon
Functors
Background image of page 1

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

View Full DocumentRight Arrow Icon
p5 Due: Monday Dec 13, 11:59pm Start now if you haven't already Any questions about p5? Stacks? Queues? RPN?
Background image of page 2
p5 Memory issues? gdb and valgrind are your friends Need help? office hours Ctools forum
Background image of page 3

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

View Full DocumentRight Arrow Icon
Functors Function Objects are objects that overload the function-call operator – these are called Functors This may not seem useful at first, but objects can have per-object state, which means that we can specialize the functors on a per-object basis
Background image of page 4
Functors - example class MultiplyN{ int factor; MultiplyN() {} // Private ctor public: MultiplyN(int n); int operator() (int n); };
Background image of page 5

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

View Full DocumentRight Arrow Icon
Functors - example
Background image of page 6
Background image of page 7

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

View Full DocumentRight Arrow Icon
Background image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: MultiplyN::MultiplyN(int n) { factor = n; } int MultiplyN::operator() (int n) { return n*factor; } MultiplyN doubleIt(2); MultiplyN tripleIt(3); cout<< doubleIt(4) << endl; cout<< tripleIt(4) << endl; We can use this function object to generate specialized functions Choose your own adventure aka. what do you want to hear about? Here are some popular topics Iterators Containers, Polymorphism, and Templates Doubly Linked Lists Deep Copies Memory Leaks Inheritance Virtual Fxns and Classes The End? Yup, that's right! P.S. Good luck on the final!...
View Full Document

This note was uploaded on 12/14/2010 for the course EECS 280 taught by Professor Noble during the Fall '08 term at University of Michigan.

Page1 / 8

eecs280.discussion.week13 - MultiplyN::MultiplyN(int n) {...

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

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