- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is type inference in C++?
Type inference or deduction refers to the automatic detection of the data type of an expression in a programming language. It is a feature present in some strongly statically typed languages. In C++, the auto keyword(added in C++ 11) is used for automatic type deduction. For example, you want to create an iterator to iterate over a vector, you can simply use auto for that purpose.
Example
#include<iostream> #include<vector> using namespace std; int main() { vector<int> arr(10); for(auto it = arr.begin(); it != arr.end(); it ++) { cin >> *it; } return 0; }
In the above program, it will automatically get the type std:: vector<int>:: iterator.
- Related Articles
- Type Inference in C++
- Type Inference in C++ (auto and decltype)
- Type Inference in Lambda expression in Java?
- Local Variable Type Inference or LVTI in Java 10
- What is Type casting in C#?
- What is Type conversion in C#?
- What is Type safe in C#?
- What is type deduction in C++?
- What is a type cast in C/C++?
- What is the difference between type conversion and type casting in C#?
- What is data type of FILE in C?
- What is enumerated data type in C language?
- What is the type of string literals in C/ C++?
- What is the type specifier for boolean in C++?
- Role of Statistical Inference in Psychology

Advertisements