P
paolo.dx
Hi, I have to overload operator= to call a method of a class, this is
what I need.
template<class I>
class port{
I dato;
public:
void write(I new_dato){
dato = new_dato;
};
I read(){
return(dato);
};
void operator= (I dato){
this->write(dato);
};
};
int main(){
int k,j;
port<int> my_port;
k=5;
my_port = k;
j = my_port; //i need to overload operator= to do my_port.read();
};
obviously I can call my_port.read() and my_port.write(k) but also I
have to be able to use the operator =
The overload for .write() is not a problem because the left side object
is an instance of class port, but how can I do for the .read()?
The operator= have to call the method .read() of the right side object,
and the left side is a standard type of c++.
Thanks in advance.
what I need.
template<class I>
class port{
I dato;
public:
void write(I new_dato){
dato = new_dato;
};
I read(){
return(dato);
};
void operator= (I dato){
this->write(dato);
};
};
int main(){
int k,j;
port<int> my_port;
k=5;
my_port = k;
j = my_port; //i need to overload operator= to do my_port.read();
};
obviously I can call my_port.read() and my_port.write(k) but also I
have to be able to use the operator =
The overload for .write() is not a problem because the left side object
is an instance of class port, but how can I do for the .read()?
The operator= have to call the method .read() of the right side object,
and the left side is a standard type of c++.
Thanks in advance.