Preamble: It was suggested a few years ago that the users who regularly monitor the c++ tag are quick to interact with questions (including voting, closing, and deleting them), according to their perception of quality. Although I have limited experience in other popular tags, I think this is probably an apt assessment. However, this is something that I see as a very good thing. Rather than discouraging it for the c++ tag, it would be nice if we could encourage this same type of engaged behavior for other tags, too.
The question got as many as three lengthy answers and many comments, which means that people did find answering my question worthwhile. Nonetheless, the question got several downvotes.
I acknowledge that the question is basic. What I thought is that, what the community of advanced of programmers finds silly, the beginners find hard or not straightforward. This discrepancy led me to ask this question. How to deal with such basic questions?
Yes, asking basic questions (assuming that they comply with our other guidelines) is perfectly fine. However, as you've noticed, there is a bit of "buyer beware" that goes along with this. That is to say, basic questions aren't always going to be well-received by experts in the field.
If you ask a reasonable, coherent question, then it's highly likely to get an answer—probably even a good answer—but that doesn't mean the question itself will necessarily get upvotes.
The logic behind that is just the fundamental purpose of the voting system. Voting here is designed to rate/rank content in terms of its usefulness and interestingness. Top-voted questions are more likely to get put in front of experts, while low-ranking questions won't be. The voting public prefers to optimize for pearls, not sand. If I come across an interesting question, I'll upvote it to ensure that other experts will see it (either to answer it, or to learn something themselves). On the other hand, if I come across a question that is a snooze-fest, I'm probably not going to upvote it, and I might even downvote it, to save others from having to waste their time with it.
It is also instructive to hover over the vote arrows and read their tooltips. The downvote arrow says:
This question does not show any research effort; it is unclear or not useful
The upvote arrow says essentially the converse. Notice two things here: "research effort", and "useful".
Questions worthy of an upvote generally need to show research effort. If you ask a basic-level question, and don't appear to have done any research, then the question is subject to being downvoted. Now, before you object, let me say that I realize this assessment is subjective. But, again, the entire voting system is subjective because it just reflects the personal opinions of users with voting privileges.
Also, questions worthy of an upvote generally need to be useful. By the same token, if a question is not useful, then it is a candidate for downvoting. Beginner-level questions whose answers can be easily found in a textbook or other resource are arguably not all that useful. (When I say "useful", I mean useful to others, not useful to the person who asked the question. Obviously they'd find the answer useful.)
Is SO a welcoming place for beginners?
This issue has been debated at length previously, and will continue to be debated into the future as long as Stack Overflow remains around. But I have a philosophical problem with the question itself. What on earth am I talking about? Well, I'm not convinced that Stack Overflow should be "welcoming". What I mean is, I don't think that should be one of our goals—yet the question presupposes that it is. Now, don't misinterpret this to mean that I think Stack Overflow should be a place inhabited by rude, snobby assholes. I don't want that, either, even though I might sometimes be one of those people. What I mean is, since we aren't a social network, our focus is not and should not be on users. So while we don't want to be unwelcoming, we don't necessarily want to be welcoming, either. The focus here is on content. Everything else is secondary. Please don't take any actions that are taken on your posts personally. They aren't directed at you as an individual.
Further reading: How can we improve the SO experience for very young programmers?