Converting between types

I'm writing a class to store a tree I have a small issue.

I have a class which stores a node of the tree, something like this:
1
2
3
4
5
6
7
8
9
template<class T>
class node
{
private:
    (stuff regarding parent node and child nodes);
    T __data;
public:
    // more stuff (constructors and utility functions) here
};


and I want to I want to be able to do the conversion T(node<T>) implicitly.

For example, I want to be able to do this:
1
2
3
4
5
6
node<int> myNode;
myNode=5;
myNode+=10;
myNode*=9;
int x=int(myNode/4);
cout << x+myNode;


and this:
1
2
3
4
5
6
7
8
9
10
11
class myClass
{
    int x;
    int y;
    void print () {cout << x << ' ' << y << endl;}
};

node<myClass> myNode;
myNode.x=6;
myNode.y=7;
myNode.print();


How could I achieve this?

Thanks!
Thanks so much!
Topic archived. No new replies allowed.