Hello
I've seen a function definition in a program. I've not seen something like that before.I tried it and it really compiles with no error. Here's the code:
1 2 3 4 5 6 7 8 9 10 11 12 13
class Y
{
public:
Y(){}
virtual ~Y(){}
virtualvoid f() //this is valid!!!
try{
std::cout<<__func__<<"\n";
}
catch(...)
{
}
};
the function definition and try block starts at the same point.is this something special? why do you think the programmer did such a thing?
Quick question - in one of the examples in the Dr.Dobbs article, he does this:
1 2 3 4 5 6 7 8
class C
{
int &r;
C(int &n)
{
r = n; // won't work!
}
};
I can't compile this, I get an error:
uninitialized reference member `C::r'
pointing to the int &r;...
Even after removing the line he says won't work, I still get a compiler error. To me, it doesn't make sense to do int &r;... Not sure what I'm looking at there (declaring an address of something that is an integer?).