I cut this from a post a made answering the very same question a week or two ago:
The answer to your question is actually fairly simple, although the official wording requires a SUBSTANTIAL explanation. We believe that “there is no salvation outside of the Catholic Church”. BUT… if you have “invincible ignorance” that the Catholic Church is the one true church, you will have a chance at salvation based on the amount of truth that you understand. Note that this does NOT mean, no matter what it looks like, that ONLY Catholics are saved!
So, in practical terms, what does that mean? First, it means that those that fully understand Catholicism and reject it probably don’t have a chance at salvation. This would include anyone who was Catholic and left the church and was accurately taught what the church really believes. (Now, if they had been raised only nominally Catholic by a family that didn’t really go to church much, they might not actually understand doctrine that well. There is a chance they could qualify as ignorant.) This would also include most of the first couple of generations of Protestants, who fully understood Catholicism and rejected it’s theology. According to Catholic theology, they are probably also doomed (although ultimately, we recognize that only God knows for sure. The church can proclaim that certain saints are in heaven, but never proclaims definitively whether someone is in hell.)
HOWEVER, most modern Christians that grow up Protestant probably do not “fully” understand Catholicism (since they really aren’t exposed to it, and what they learn is often inaccurate), and so there is a good possibility that they may be “invincibly ignorant”, in which case, they will be judged by what they understand. They would still have the benefit of many proper Christian teachings (those that mirror Catholic teaching), though they would be undermined by a few incorrect ones (which may or may not be important ones, depending on the denomination). Clearly, there are Protestants in heaven. (Of course, if they later studied Catholicism and truly understood it, and STILL rejected it, then they would likely be doomed.)
Non-Christians very well might be “invincibly ignorant”, but have even less understanding of Catholic Christianity than Protestants, and so, it would still be possible, but perhaps increasingly unlikely that they would merit heaven. They would have to do their best to follow God by following natural law, and recognize that there was some higher power. In all of these cases, it seems likely that the further your belief differs from Catholicism, the less likely it is that you could obtain salvation because it would become increasingly difficult to know HOW to do so, although there is the possibility for EVERYONE, and surely there are non-Christians in heaven as well.
The biggest problem for all of these groups is that they lack the benefit of a sacramental confession, so if they EVER committed a mortal sin, about the only way it could be removed would be through an Act of Perfect Contrition, meaning they would have to be truly sorry, NOT just because they were afraid of hell, but because they were sorry that they offended God. (Or, if they were baptized in the Trinitarian formula and never committed a mortal sin, they would go to heaven, since baptism removes original sin.) If one isn’t even Christian, you can see how this might be extremely difficult. How would a non-Christian even KNOW what an Act of Perfect Contrition was? (There is also the possibility that they could make a “baptism of desire”, like the thief on the cross.) Thus, when someone outside of the Catholic faith DOES make it to heaven, it is STILL “through (the teachings preserved in) the Catholic Church.”