If I were to launch a CubeSat, how long would it last before falling out of orbit and burning up in the atmosphere?
gerrit is right, the most important restricting factor for the life-time in orbit is the orbit of the launcher. But I think a few details could be useful, anyway ...
Although cubesats are fairly similar (well, cubes), there are a few differences. There are 1, 2, 3, 6 and 12U cubesats. Besides, a lot of projects do not care about the weight restriction (one kg per one U) anymore, so there are plenty of over-weight (and some under-weight) cubesats in space. Some cubesats have deployable solar arrays, a lot have (different types of) deployable antennas. All of those factors account for differences in orbital decay. However, fundamentally, the decay still depends on the altitude (perigee and apogee) of the orbit.
A few numbers for circular orbits and 1U cubesats: ~1 year @ 450 km, 25 years @ 640 km (maximum allowed life time in or below geosynchronous orbit for every satellite launched in 2008 or later - IADC).
An interesting paper by AGI: An Evaluation of CubeSat Orbital Decay, 2011.
(Feel free edit in a graph, which is not copyright-protected - cant find anyone.)
That depends very much on the launch you're piggybacking with.
When you launch a CubeSat, you're entirely at the whim of the launch you're piggybacking on. CubeSats usually don't have propulsion so if it's a low orbit, it may take only weeks before you burn up in the atmosphere. At a slightly higher orbit it may be a couple of months. As most CubeSats are for technology demonstration or as student projects, this is entirely sufficient. But there is no generic answer that applies to all CubeSats.