cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
handling data types as inputs
handling data types as inputs
Apr 10, 2013 at 5:03pm UTC
MA WiSo
(5)
I 'm fairly new to C++ programming. I wanted to accept a datatype as an input. I've seen something similar while working with the <queue> library.
when defining a new object of queue
for example:
queue<
int
> Queue;
how is <int> handled ??
Apr 10, 2013 at 5:29pm UTC
pogrady
(677)
std::queue<typename> is a template. It tells the compiler how to build the object at compile time instead of hard coding a class which handles only one datatype.
In this example, you are creating a queue of integers. If you did this:
std::queue<float> Queue;
you would create a queue of floats.
Topic archived. No new replies allowed.