C++ keyword definition request

Pages: 12
Hello. I did not know it, but, the C++ book I read was pretty outdated.
And I would like to know what the following keywords do:

#pragma ,
extern,
template,
typename,
explicit
(Maybe more, I forget.)

Please help.

Thanks.
Last edited on
https://en.cppreference.com/w/cpp/keyword

#pragma is a bit different since it is not an official C/C++ keyword, it has lots of implementation defined uses.
https://en.cppreference.com/w/cpp/preprocessor/impl

FYI......

Searching the 'net for your questions first might be of more benefit to you. You learn how to ask questions correctly for the search, and telling people you've already looked when you can't find any good answers makes people more willing to help.

The cppreference site is chock full of answers just waiting for you, so is stackoverflow. Those are two sites I constantly dig around in.
Thanks.
if the documentation does not say it, watch out for pragma as those are frequently nonstandard / not portable.
Last edited on
Ok, well, can anyone explain the keywords?
Find and read the documentation for the keywords you are interested in. There is plenty of documentation for the keywords in the C++ language on the net.

Ok, I just thought I could get answers here. I guess 13 year-olds shouldn't try to learn complex things like C++. Lol
Ok, I just thought I could get answers here

You're asking too much.

Why should I bother to summarize this information for you, if you're too lazy to look it up yourself?
http://www.catb.org/esr/faqs/smart-questions.html#before
Last edited on
can anyone explain the keywords?

That cppreference keywords link has links to the reserved keywords. Click one and find out what it has to tell you, if you take the time to read.

I just thought I could get answers here.

The BEST answers you can get for your questions are the ones you research on your own. Then you will retain better the information. It doesn't matter what your age happens to be.

Most 13 year-olds don't want to have old farts like us just telling them everything, they want to discover the answers themselves. The more complex the subject makes doing the work all the more enjoyable.

Learn how to learn on your own, there are VAST resources available in books and on the internet if you take the time and make the effort to dig for the information yourself.

I am self-taught for programming with C++. No classes or schooling. Reading books, searching the internet -- trying out examples I find whenever something new pops up -- is what I did and still do.

I've been trying to learn C++ back in the 1980's and 1990's. And doing it badly, but I learn what I want to learn at my own pace. C++ before it was "modern C++." Before C++11 and later.

You asked about keywords (and #pragma). What I first did before I replied to you was go to cppreference and see what they have to offer. If doing that was too abstract for me to understand -- after all cppreference is a reference site, not a tutorial -- I'd next look at stackoverflow or Learn C++. If that still doesn't really answer my question(s) I'd do a generic 'net search, something like "C++ keywords".

After all that if I still can't find what I'm looking for in easy to digest chunks -- a human trying to eat a whole cow is rather difficult -- I might, MIGHT, ask the question here. Explaining all the effort I already expended.

A lot of times questions others ask and the answers given help me to understand something that was murky before. This is a good example:

Visual Studio - Connecting a Library
http://www.cplusplus.com/forum/lounge/271176/

I didn't ask the question, but I sure learned from it, as well as the answers given. The problem has been one that had been bugging me for quite some time.

Something else I do is when I run across a web page/site that has some info that looks especially interesting I copy the link and save it for later. I bookmark the site.

Long story short, we can HELP you only when you show you WANT to learn. Simply expecting us to be free tutors as if that was your divine right is not going to make people want to help you.
Why should I bother to summarize this information for you, if you're too too lazy to look it up yourself?


If you have nothing nice to say, then keep your mouth shut.

Last edited on
The people in this forum have a lot of patience with beginners. What mbozzi said is absolutely true. Try doing more research yourself, like searching for "C++ explicit keyword examples", etc.

(But I will say, implicit is not a C++ keyword)
Last edited on
@Alexander123

https://philosiblog.com/2015/09/01/he-who-asks-a-question-is-a-fool-for-five-minutes-he-who-does-not-ask-a-question-remains-a-fool-forever/

1. Go to https://www.learncpp.com/ and conduct the word search there.
2. The tutorial section here https://www.cplusplus.com/doc/ is a useful resource too but not as up to date.

:)
Ok, Ganado, I thought I saw that keyword somewhere.

Thanks, @againtry.
It’s a keyword in other languages, Alexander123: I think it’s a keyword in C# and scala and it’s definitely a keyword in fortran.

But of those you list, one of the most useful is probably “template”: allowing you to define generic functions working for many types of argument.
Simply,

extern is to specify that the stated variable is defined elsewhere (eg another compilation unit)

typedef is used to give a name to a type. Now replaced with using.

eg
typedef std::vector<int> VINT;

using VINT = std::vector<int>;

VINT myvect;

explicit is used when defining a class/struct constructor to specify that the constructor must be specifically specified when used and not as part of a type conversion.
Last edited on
Ok, I just thought I could get answers here. I guess 13 year-olds shouldn't try to learn complex things like C++. Lol


you certainly can learn c++, but before you do, you should learn how to search the web.
I mean, I can tell you what template is, for example. Its a way to make user defined types (class, struct) able to accept a variety of inputs (like how the vector<> type in c++ can be used to make a vector of int, double, or myidioticclassfullofwhatevers). But there is more to it that would take a good page to really cover it well enough that you could actually USE it.
I don't want to type that full page.
I can also look it up for you and get a link to a page that you can click on and read it for yourself. But why, when you can do that too, with 2 seconds invested. And, the web is likely to give you a better answer than I can type here; I am a terrible teacher and forget details that I don't care about very often, etc.

We want to help you, but there are some places, some times, when you need to help yourself first. If you read a good site on what something is and STILL don't understand it, no one minds going over that -- a lot of technical stuff is going to be hard to read at 13, and we know that.
typename is used to give a name to a type. Now replaced with using

That's typedef, whereas typename is used to disambiguate dependent types.
You likely saw implicit in the context of implicit conversions.
https://en.cppreference.com/w/cpp/language/implicit_conversion

For example, converting a floating point value when stored in an integer variable.
That's typedef, whereas typename is used to disambiguate dependent types.


Sorry. My bad. It was late Saturday night and I had enjoyed the whiskey..... Post changed
Last edited on
This is going to sound harsh. It's not meant to be; it's meant as a genuine explanation that is intended to help you have better interactions with people here.

Ok, I just thought I could get answers here.

Yes, but sometimes, "getting answers" means asking people to take time and effort to retype information that has already been written elsewhere and is really, really easy to look up yourself. There is absolutely no value in doing this - it's just asking other people to do needless makework.

Asking someone to type up a basic tutorial on what certain keywords mean, just for you, when there are already countless tutorials and references available just a Google search away, is such a question.

You do understand that none of us are paid to be here and answer questions, yes? That we're all just ordinary people with jobs and lives, giving up our time and effort to answer questions, yes? And that expecting us to do meaningless makework for an online rando, just because you don't want to Google something, is a little rude?

I gues 13 year-olds shouldn't try to learn complex things like C++.

What a bizarre non-sequitur. Nobody here has remotely suggested that your age has anything to do with anything. In fact, I'd guess none of us here had the slightest clue how old you are until you said this.
Last edited on
Pages: 12