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

This is a discussion on What happens here? (Bad thread name, I know) within the C++ Programming forums, part of the General Programming Boards category; Hallo, I have this small extract of code from a book I have. But I don't really understand what is ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,452
    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...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

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, 09:10 AM
  2. Thread confusion
    By pyrolink in forum C Programming
    Replies: 0
    Last Post: 01-29-2006, 08:42 PM
  3. CreateThread ?!
    By Devil Panther in forum Windows Programming
    Replies: 13
    Last Post: 11-15-2005, 09: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21