- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Found 9321 Articles for Object Oriented Programming
![Lakshmi Srinivas](https://www.tutorialspoint.com/assets/profiles/13528/profile/60_91717-1512651120.jpg)
241 Views
Auto is a keyword in C++11 and later that is used for automatic type deduction. 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. For example, you want to create an iterator to iterate over a vector, you can simply use auto for that purpose. example#include #include using namespace std; int main() { vector arr(10); for(auto it = arr.begin(); it != arr.end(); it ++) { cin >> *it; } return 0; }In ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
129 Views
You can initialize a variable using the assignment operator or use its constructor when initializing it. For example,int i = 0; MyClass instance(1, "Hello");It will be automatically initialized ifIt's a class/struct instance in which the default constructor initializes all primitive types; like MyClass instance; You use array initializer syntax, e.g. int a[10] = {} (all zeroed) or int a[10] = {1,2}; (all zeroed except the first two items: a[0] == 1 and a[1] == 2) It is a global/extern variable It is defined static
![Vikyath Ram](https://www.tutorialspoint.com/assets/profiles/13780/profile/60_74413-1512648006.jpg)
900 Views
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 #include using namespace std; int main() { vector arr(10); for(auto it = arr.begin(); it != arr.end(); it ++) { cin >> *it; } return 0; ... Read More
![Swarali Sree](https://www.tutorialspoint.com/assets/profiles/13515/profile/60_84115-1512649510.jpg)
305 Views
If you have statements like −Class Person;This is a forward declaration. It lets the following code know that there is are classes with the name Person. This satisfies the compiler when it sees these names used. Later the linker will find the definition of the classes.
![Sai Subramanyam](https://www.tutorialspoint.com/assets/profiles/13512/profile/60_68191-1512710774.jpg)
1K+ Views
In C++, declaration and definition are often confused. A declaration means (in C) that you are telling the compiler about type, size and in case of function declaration, type and size of its parameters of any variable, or user-defined type or function in your program. No space is reserved in memory for any variable in case of the declaration. The Definition on the other hand means that in additions to all the things that declaration does, space is additionally reserved in memory. You can say "DEFINITION = DECLARATION + SPACE RESERVATION". Following are examples of declarations − extern int ... Read More
![Paul Richard](https://www.tutorialspoint.com/assets/profiles/13505/profile/60_52698-1512536733.jpg)
160 Views
To define a variable in C++, you need to use the following syntax −Syntaxdatatype variable_name;You need to know what type of data is your variable is going to hold and what it will be called. The variable name has constraints on what you can name it. Following are the rules for naming variables −Variable names in C++ can range from 1 to 255 characters.All variable names must begin with a letter of the alphabet or an underscore(_).After the first initial letter, variable names can also contain letters and numbers. Variable names are case sensitive.No spaces or special characters are allowed.You ... Read More
![Monica Mona](https://www.tutorialspoint.com/assets/profiles/13520/profile/60_87298-1512650151.jpg)
458 Views
In C++, declaration and definition are often confused. A declaration means (in C) that you are telling the compiler about type, size and in case of function declaration, type and size of its parameters of any variable, or user-defined type or function in your program. No space is reserved in memory for any variable in case of a declaration.The Definition on the other hand means that in additions to all the things that declaration does, space is additionally reserved in memory. You can say "DEFINITION = DECLARATION + SPACE RESERVATION".Following are examples of declarations −extern int a; ... Read More
![Kumar Varma](https://www.tutorialspoint.com/assets/profiles/13883/profile/60_73481-1512711460.jpg)
282 Views
An enumerated type declares an optional type name and a set of zero or more identifiers that can be used as values of the type. Each enumerator is a constant whose type is the enumeration. For example, if you are creating an application that has a fixed number of types for some variable. For example, let's say gender, it can be of three types male, female and others. You can define and use an enum like −#include using namespace std; enum Gender {MALE, FEMALE, OTHERS}; int main() { Gender gen = Gender.FEMALE; return 0; }By default, the value ... Read More
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
698 Views
An enumerated type declares an optional type name and a set of zero or more identifiers that can be used as values of the type. Each enumerator is a constant whose type is the enumeration. For example, if you are creating an application that has a fixed number of types for some variable. For example, let's say gender, it can be of three types male, female and others. You can define and use an enum like −#include using namespace std; enum Gender {MALE, FEMALE, OTHERS}; int main() { Gender gen = Gender.FEMALE; return 0; }By default, the value ... Read More
![Fendadis John](https://www.tutorialspoint.com/assets/profiles/13534/profile/60_64028-1512539837.jpg)
338 Views
The typedef keyword in C++ can be used to give a type a new name. For example, you can give a new name of BYTE to unsigned characters −typedef unsigned char BYTE;After this type definition, the identifier BYTE can be used as an abbreviation for the type unsigned char, for example −BYTE b1, b2;This will declare 2 variables b1 and b2 of type unsigned char. Typedefs are really useful when you have huge names due to namespaces, class names, etc. For example, if you want a variable of type std::vector::iterator multiple times throughout your program. You can just rename it ... Read More