[Univ of Cambridge] [Dept of Engineering]

C++ Exercises

  1. Write a class called testing so that the following main function works
    int main()
      // create some objects of type 'testing', setting a value member to the given value
      testing a(1),b(2);
      // print the number of objects of type 'testing' and their values
  2. Which line below causes the compiler to report an error? Why? If it's removed, and the resulting program run, what does it print out? Why?
    #include <iostream>
    using namespace std;
    int foo(int i) {
      cout << i << endl;
    int main() {
[contents page] [talk 1] [talk 2] [talk 3] [talk 4]

[C++] [Help]

Updated June 2008
tpl@eng.cam.ac.uk (copyright © CUED, 2002)