1) please use
[code] ... [/code] tags when posting code.
2) Your code contains a lot of error. It doesn't even compile without modifications.
i) class definitions need to end with a semicolon:
Code:
class testA {
...
};
class testB {
...
};
ii) if you want to call a constructor of static member
testA that is declared within
testB, you should make the constructor public:
Code:
class testA
{
public:
testA(int a,int b) throw (int) { ... }
}
...
testA testB:bject(92,100);
iii) one colon after
public is enough:
Code:
class testB
{
public::
...
}
iv) your
main() is missing a brace:
Code:
int main()
{
try {
testB::init();
}
catch (int &e)
{
printf("exception ocurred");
}
return 0;
}
Anyway, if you fix all the errors, the proram will crash with an unhandled exception error. Why? Just read your code:
Code:
testA testB:bject(92,100);
this is where you initialise your static member. This is actually done before
main() is called and therefore not within your
try --
catch construct. Why would
testB::init, which is in your
try block cause an exception being thrown is beyond me.