Thread: What happens here? (Bad thread name, I know)

  1. #1
    Registered User
    Join Date
    Oct 2006
    Location
    UK/Norway
    Posts
    485

    What happens here? (Bad thread name, I know)

    Hallo,

    I have this small extract of code from a book I have. But I don't really understand what is going on here. Is t0 and t1 given values in this code, even though Quadratic does not return anything (its a bool)?

    Code:
    	// Solve quadratic equation for _t_ values
    	float t0, t1;
    	if (!Quadratic(A, B, C, &t0, &t1))
    		return false;
    	// Compute intersection distance along ray
    	if (t0 > ray.maxt || t1 < ray.mint)
    		return false;
    Thanks

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quadratic gets pointers to the t0 and t1, so it can modify its values using these pointers... And obviously does it because t0 and t1 are not initialized before the call. At least they should be initialized inside the function when the function returns true... They can be still not initialized if the function returns false...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. API Thread HEADACHE
    By WaterNut in forum Windows Programming
    Replies: 11
    Last Post: 01-16-2007, 10:10 AM
  2. Thread confusion
    By pyrolink in forum C Programming
    Replies: 0
    Last Post: 01-29-2006, 09:42 PM
  3. CreateThread ?!
    By Devil Panther in forum Windows Programming
    Replies: 13
    Last Post: 11-15-2005, 10:55 AM
  4. pointer to main thread from worker thread?
    By draegon in forum C++ Programming
    Replies: 2
    Last Post: 10-27-2005, 06:35 AM
  5. STL thread safety
    By Hunter2 in forum C++ Programming
    Replies: 4
    Last Post: 10-06-2004, 08:09 PM