Thursday, July 28, 2005

More C++ Notes

Started to relearn C++ again:

Here are some things I wish to note:

using namespace FRN_MAIN
- using software components from the FRN_MAIN libaries
- makes the libaries + functions unique from other libs. Good for libs that have the same method / function names--> so qualifiy the name space.
- Each namespace defines a scope where global ident + global variables are place

You can also explicitly use the name space in the manor of
namespace _name::member

Note on Extern

extern "C" function prototype
extern "C" function { blocks }
- tell the compiler do not compile the extern in C++ do it at the linker level.

Polymorphism / Dynamic allocated Objects
- in an inherited situation calling delete on an object will use the base class destructor use virtual to get around this issue.

Intresting subquery

Intresting query to make a sub select.

For 4.0.x you'd need a temporary table instead of the subselect:

SELECT x1.category, x1.itemid, COUNT(x2.category) AS rank
FROM mytbl x1
LEFT JOIN mytbl x2 ON x2.category = x1.category
AND x2.itemid = x1.itemid
AND x2.timemodified < x1.timemodified
GROUP BY x1.category, x1.itemid;

FROM mytbl r1
JOIN tmp r2 ON r2.category = r1.category AND r2.itemid = r1.itemid
ORDER BY r1.category, r2.rank DESC, r1.timemodified DESC;