So I have this simple class, that throw an array, so the main can catch it and interpret it
#include "r0t0r.h"
using namespace std;
rotor::r0t0r(){
int a[2]={5,6};
throw a;
}
In my main, I try to catch this array:
int main(int argc, char **argv){
try{
r0t0r a;
std::cout << "123" << std::endl;
}
catch(int e[2]){
std::cout << e[0] << std::endl;
}
}
but my output is some gibberrish.
Help?
Edit:
I just tried the below, it is due the empty constructor.
class rotor{
public:
rotor();
rotor(int a[2]);
};
rotor::rotor(){
int b[2]={12,2};
throw b;
}
rotor::rotor(int a[2]){
throw a;
}
using namespace std;
int main(int argc, char **argv){
try{
//int b[2]={12,2};
//rotor a(b);
//this output perfect with a contructor with argument
rotor a;
//this output gibberish
}
catch(int e[2]){
std::cout << e[0] << std::endl;
}
}