20-CS-122-001 Computer Science II Spring 2012
What's Up With **?

Virtual functions, classes, inheritance, lists, queues, stacks, applications

Prev      Next      Lectures      Source

// Sample use of "**"
#include <iostream>
using namespace std;

class A {
public:
   long long number;
   A() { number = 10; }
   A (long long number) { this->number = number; }
};

ostream &operator<<(ostream &out, A &a) {
   out << a.number;
   return out;
}

int main () {
   A **a = new A*[10];
   for (int i=0 ; i < 10 ; i++) a[i] = new A(i+12);
   cout << **a << " " 
	<< **(a+1) << " " 
	<< **(a+2) << "\n";
}
// Output: "12 13 14"