raytracing.github.io icon indicating copy to clipboard operation
raytracing.github.io copied to clipboard

Listing 2.71 / interval scope operator inconsistency

Open hollasch opened this issue 2 years ago • 1 comments

Benny Tsang writes:

(Book 2) Section 9.1, Listing 71, when calculating the first hit record (rec1), the "interval::" scope operator may not be needed. In Book 1's Listing 26 (where interval.h was first created), the interval universe was not defined within the scope of interval class. It also didn't affect the flow of the chapter, but it would be good to have consistent codes across different chapters.

hollasch avatar Oct 27 '23 20:10 hollasch

Hi sir I ran into this issue today. If I actually use "interval::universe" instead of "universe", I would get a Linking Error "1>main.obj : error LNK2001: unresolved external symbol "public: static class interval const interval::universe" (?universe@interval@@2V1@B)" image

This error does not happen after I removed the "interval::" before the variable "universe"

cccccz avatar Feb 04 '24 11:02 cccccz

I think our two versions of interval.h may be different. The following should be used:

class interval {
    ...
    static const interval empty, universe;
};

const interval interval::empty    = interval(+infinity, -infinity);
const interval interval::universe = interval(-infinity, +infinity);

Is this the code that's giving you a link error?

hollasch avatar Feb 20 '24 09:02 hollasch

@cccccz The issue has been addressed in dev I'm going to close out this issue. Let us know if you still have any issues.

rupsis avatar Mar 08 '24 14:03 rupsis