int * foo //is a pointer int * & fooRef //is a reference to an int pointer.
int x int & xRef = x; int * xPtr = & xRef;
void Swap (int & a, int & b) {
int tmp;
tmp = a;
a = b;
b = tmp;
}
int * ptr1; int * ptr2; .... Swap(ptr1, ptr2);
Swap(*ptr1, *ptr2);
class Address() {
public:
private:
vector<string> addressLines(4);
string city;
string state;
int zip;
}
class Person {
public:
Person():
~Person():
Person(const Person & person);
private:
Address address;
string name;
};
bool ValidPerson1(Person p);
bool ValidPerson2(const Person & p);
class BoardT;
class PieceT {
PieceT(BoardT & boardRef): theBoard(boardRef) ...{
}
private:
BoardT & theBoard;
// could be const if we know the piece will not change the board.
};
class BoardT {
...
void AddPiece(PieceT & piece);
private:
vector <PieceT *> pieces;
};