1. What is wrong with this code?
#include class myIntVector : public std::vector<int> {};
2. What is the difference between line A and line B?
#include int main(){ std::vector<int> foo(4, 2); std::vector<int>::iterator itor( foo.begin() ); *itor++; // A (*itor)++; // B}
3. What is the output of this program?
#include #include class foo{public: foo() {std::cout << "constructor called" << std::endl;} foo(std::string grue) {std::cout << "constructor taking a string called" << std::endl;}};int main(){ foo bar; foo baz("You are in a maze of twisty little passages, all alike"); foo xyzzy();}
4. What is the difference between line A and line B?
std::vector<int>::const_iterator foo // A;const std::vector<int>::iterator bar; // B
5. What is the output of this program?
#include class foo{public: ~foo() {std::cout << "foo's destructor called" << std::endl;}};class bar{public: ~bar() {std::cout << "bar's destructor called" << std::endl;}};int main(){ foo Guybrush; static bar Threepwood; exit(0);}
b) typedef ftw!
c) possbily something about symbol lookup making it hard to call functions of myintvector
2. *itor++ advances the iterator and dereferences it
(*itor)++ calls operator++() on the element now pointed at by itor
3. constructor called
constructor taking a string called
4. a) cannot modify the foo
b) cannot modify the iterator either
5. I think its just "foo's destructor called"
That was fun...