//: C02:Fillvector.cpp
// Copy an entire file into a vector of string
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;

int main() {
  vector<string> v;
  ifstream in("Fillvector.cpp");
  string line;
  while(getline(in, line))
    v.push_back(line); // Add the line to the end
  // Add line numbers:
  for(int i = 0; i < v.size(); i++)
    cout << i << ": " << v[i] << endl;
} ///:~

// in U++ it would be
int main() {
  Vector<String> v;
  ifstream in("Fillvector.cpp");
  String line;
  while(getline(in, line))  // getline() is U++?
    v.Add(line); // Add the line to the end
  // Add line numbers:
  for(int i = 0; i < v.GetCount(); i++)
    cout << i << ": " << v[i] << endl;
} ///:~


If you declare the class you do not need extern...

//: C05:Friend.cpp /////////////////////////////////////////
// Friend allows special access

// Declaration (incomplete type specification):
struct X;

struct Y {
  void f(X*);
};

struct X { // Definition
private:
  int i;
public:
  void initialize();
  friend void g(X*, int); // Global friend
  friend void Y::f(X*);  // Struct member friend
  friend struct Z; // Entire struct is a friend
  friend void h();
};

void X::initialize() { 
  i = 0; 
}

void g(X* x, int i) { 
  x->i = i; 
}

void Y::f(X* x) { 
  x->i = 47; 
}

struct Z {
private:
  int j;
public:
  void initialize();
  void g(X* x);
};

void Z::initialize() { 
  j = 99;
}

void Z::g(X* x) { 
  x->i += j; 
}

void h() {
  X x;
  x.i = 100; // Direct data manipulation
}

int main() {
  X x;
  Z z;
  z.g(&x);
} ///:~
/////////////////////////////////// end friends ///////////////////

il costruttore della classe derivata attiva anche il ctruttore della classe 
da cui deriva! 
