If you need to return more than a single variable, then you probably have a design issue.
I think it might work best like this (in general):
int val1, val2;
VersionDatachecker vd = new VersionDatachecker();
vd.go(list, of, variables);
val1 = vd.getVal1();
val2 = vd.getVal2();
That's likely a cleaner design, and more "proper", in many respects.
Creating an object to return a parameter value is a gross kludge. It was a killable offense back when I was a marker.
Just to expand on what unTactical said, as well as being a big C/C++/Fortran programmer (though I hate Fortran!), it is not only common to wish to return multiple pieces of data, but the ability to do so is built into all three of these languages.
While, C/C++ provide structs and classes, to "return" multiple pieces of data, Fortran actually defines a class of "subprogram" known as a "subroutine"
A subroutine is basically a C++ void function that accepts all references.
Here's a practical example where I want two pieces of data returned in fortran (95):
SUBROUTINE boxmuller(x,y)
IMPLICIT NONE
DOUBLE PRECISION, PARAMETER :: PI = 3.14159265359d0
DOUBLE PRECISION, INTENT(OUT) :: x, y
DOUBLE PRECISION :: u1, u2
CALL RANDOM_NUMBER(u1)
CALL RANDOM_NUMBER(u2)
x = SQRT(-2.d0*LOG(u1))*COS(2.d0*PI*u2)
y = SQRT(-2.d0*LOG(u1))*SIN(2.d0*PI*u2)
END SUBROUTINE boxmuller
This returns two independent variates distributed on N(0,1) generated from Box-Muller.
Here's a practical example in C
int tunman_getaddr( struct tunman *tn, struct sockaddr *addr, struct sockaddr *b
road ) {
struct ifconf ifc;
struct ifreq ifr;
int s = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
if ( s == -1 ) return -1;
memset( &ifc, 0, sizeof(ifc) );
strncpy( ifr.ifr_name, tn->ifnam, sizeof( ifr.ifr_name ) );
ifc.ifc_len = sizeof(ifr);
ifc.ifc_req = 𝔦
if ( ioctl( s, SIOCGIFCONF, &ifc ) == -1 ) {
close( s );
return -1;
}
close( s );
memcpy( addr, &ifc.ifc_req->ifr_addr, sizeof(*addr) );
memcpy( broad, &ifc.ifc_req->ifr_broadaddr, sizeof(*broad) );
return 0;
}
In this example, I not only return an indicator for error, but I also return two pieces of information, an interface's IP address and broadcast address. The ioctl() SIOCGIFCONF also returns a buffer of ifreqs that hold the interface's IP address and aliases. These types of operations are very common in Unix...doing something like:
getipaddr("eth0", &ip);
getbroad("eth0",&broad);
getmask("eth0", &mask);
getstate("eth0", &up );
etc...is extremely redundant!