Question: I am using a simple TABLE to display tabular data where the rows need to line up but when it comes to selecting the table contents, I only want users to be able to select within each column. Default browser behaviour is to select as rows across all columns but we NEED somehow allow selection only within columns.

I was hoping there was a fancy new CSS or XHTML 1.0 way to define tables as columns instead of rows and browsers would then force selection within them. I know realize this probably isn't possible and will need to build a javascript selection way to override browser selection. Obviously javascript spreadsheet widgets like Google Spreadsheets allow selection within rows and columns as I require but I am hoping to find a grid-type widget built on Prototype or write my own functionality.

Any tips or links to widgets with this column selection builtin? Is there an HTML/CSS trick to make something like this work?

Answer: 
Your problem is that you should accept a reference in your function. The reason is that a reference does not actually copy the argument passed. If you however accept an `A` - instead of a reference `A&` - then you actually copy the argument passed into the parameter object, and what you get is an object of type `A` - but which is actually not allowed!

```
    // the reference parameter will reference the actual argument
    void setInstance(A &newInstance) {
            // assign the address of the argument to the pointer member
            // instance. 
            instance = &newInstance;
    }

```

And then you will have to change the member in your class to be a pointer. It can't be a reference because `setInstance` will change what it references - a reference can only reference one object during its entire lifetime, while a pointer can be set to point do different things just by reassigning it a different address. The remaining parts look like this then

```
    void doSomething() {
        // call a member function on the object pointed to
        // by instance!
        instance->action();
    }

private:

    // a pointer to some object derived from A
    A *instance;

```

Also note that you have to compile C++ programs using `g++`, because it additionally links the C++ standard library to your code

```
g++ -o test test.cpp # instead of gcc!

```
Your problem now is a linkage.
For C++ program, standard C++ library has to be added:

gcc -o test **-lstdc++** test.cpp