Victor,
My answer may seem harsh to you, but please bear in mind that my aim is
to provide you with some guidelines for effectively getting meaningful
help from this group.
Top-posting fixed. Please don't top-post on usenet. Look at this:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.4
Victor Hannak wrote:[color=blue]
> Atilla wrote:[/color]
<snip>[color=blue][color=green]
>> since you did not post the code, only a fragment)<snip>[/color]
> I'm not sure how much more code I need to post, after all, the segment I
> included is the portion that's causing the exception.[/color]
What ever you post, it should be compilable. That means that we should
be able to cut and paste exactly what you've posted and compile it and
see the same problem you're seeing. This will require some effort on
your part, as you will have to isolate the problem. The upside is that
this is often enough to figure out what the problem is without waiting
for a response on usenet.
[color=blue]
> I would think that no
> matter what my program does (to the result variable) before this code is
> called should be irrelevant.
> <snip>[/color]
This is almost certainly not true. I've added a minimal amount of code
required to turn your fragment into a compilable unit (see below), and
no exception is thrown. That seems to indicate that the problem is not
in the fragment you posted.
-----------------
#include <iostream>
class FuncClass
{
public:
FuncClass(float r) : Result(r) {}
float GetResult();
private:
void WriteString(const char* s)
{
std::cerr << s << '\n';
}
float Result;
};
float FuncClass::GetResult() {
try {
return(Result);
} catch (...) {
WriteString("FuncClass::GetResult ERROR: Exception encountered");
return(0);
}
}
int
main()
{
FuncClass fc(1.0);
std::cout << fc.GetResult() << '\n';
return 0;
}
-----------------
- Adam