C
Cruxic
Can a class constructor be an argument default? It works in Borland
C++ but not in MinGW
The following won't compile in MinGW because of the error "Invalid
type 'Thing1' for default"
===========================
#include <stdio.h>
#include <stdlib.h>
class Thing1
{
public:
int mInt;
Thing1() {mInt = 123456789;}
};
class Thing2
{
public:
int mInt;
public:
void setInt(Thing1 & t = Thing1()) {mInt = t.mInt;} //PROBLEM IS
HERE!
};
int main(int argc, char *argv[])
{
Thing2 t2;
t2.setInt();
printf("%d\n", t2.mInt);
system("PAUSE");
return 0;
}
==========================
So, is this type of default argument non-standard?
Much Thanks,
Adam
C++ but not in MinGW
The following won't compile in MinGW because of the error "Invalid
type 'Thing1' for default"
===========================
#include <stdio.h>
#include <stdlib.h>
class Thing1
{
public:
int mInt;
Thing1() {mInt = 123456789;}
};
class Thing2
{
public:
int mInt;
public:
void setInt(Thing1 & t = Thing1()) {mInt = t.mInt;} //PROBLEM IS
HERE!
};
int main(int argc, char *argv[])
{
Thing2 t2;
t2.setInt();
printf("%d\n", t2.mInt);
system("PAUSE");
return 0;
}
==========================
So, is this type of default argument non-standard?
Much Thanks,
Adam