which one of the two codes is right and why ?
C C::operator++() {
    x++; 
    y++; 
    return *this; 
}
C & C::operator++() {
    x++; 
    y++; 
    return *this; 
}
Thanks
which one of the two codes is right and why ?
C C::operator++() {
    x++; 
    y++; 
    return *this; 
}
C & C::operator++() {
    x++; 
    y++; 
    return *this; 
}
Thanks
 
    
     
    
    The second one is the idiomatic one: a parameter-less operator++ is the pre-fix increment operator, which should return a reference to self.
 
    
    Both are "correct", but the second is idiomatic, because it's expected that the prefix operator ++ returns an lvalue.
