March 20, 1999

Determine Absolute Cursor Coordinates

When a component event such as a mouse click occurs, Java provides the cursor coordinates relative to the top left corner of the component in which the event took place. However, it can be useful to determine the cursor’s absolute screen position instead. For example, you could use this information

Friends Should be Declared Public

The compiler ignores the access specifier of friend functions. However, you should declare them as public to make the code readable: bool operator ==( const Date & d1, const Date& d2); class Date{ private: int day, month, year; public: friend bool operator ==( const Date & d1, const Date& d2);

Dynamically Create Selection Box Options

You can create selection box options dynamically using JavaScript 3.0’s Option object. The syntax for its constuctor is: Option(text, value, [default selected], [selected]) Here is an example:

Empty Exception Specification

Some programmers tend to add an empty exception specification to constructor destructor, assignment operator, and copy constructor of a class: class C {public: C() throw(); ~C() throw(); C(const C&) throw(); C& operator= (const C&); throw();}; On some implementations, this practice can improve performance, because the compiler is free not to