![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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 34549 Articles for Programming
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
15K+ Views
Constructors are functions of a class that are executed when new objects of the class are created. The constructors have the same name as the class and no return type, not even void. They are primarily useful for providing initial values for variables of the class. The two main types of constructors are default constructors and parameterized constructors.Default constructors do not take any parameters. If a default constructor is not provided by the programmer explicitly, then the compiler provides a implicit default constructor. In that case, the default values of the variables are 0.A program that demonstrates default constructors is ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
17K+ Views
Destructors in C++ are members functions in a class that delete an object. They are called when the class object goes out of scope such as when the function ends, the program ends, a delete variable is called etc.Destructors are different from normal member functions as they don’t take any argument and don’t return anything. Also, destructors have the same name as their class and their name is preceded by a tilde(~).A program that demonstrates destructors in C++ is given as follows.Example Live Demo#include using namespace std; class Demo { private: int num1, num2; public: Demo(int n1, ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
9K+ Views
Constructors are functions of a class that are executed when new objects of the class are created. The constructors have the same name as the class and no return type, not even void. They are primarily useful for providing initial values for variables of the class.The two main types of constructors are default constructors and parameterized constructors. Details about these are given as follows.Default ConstructorsDefault constructors do not take any parameters. If a default constructor is not provided by the programmer explicitly, then the compiler provides a implicit default constructor. In that case, the default values of the variables are ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
23K+ Views
A nested class is a class that is declared in another class. The nested class is also a member variable of the enclosing class and has the same access rights as the other members. However, the member functions of the enclosing class have no special access to the members of a nested class.A program that demonstrates nested classes in C++ is as follows.Example Live Demo#include using namespace std; class A { public: class B { private: int num; public: void getdata(int n) { num = n; } void putdata() { cout
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
2K+ Views
A class declared inside a function is known as a local class in C++ as it is local to that function.An example of a local class is given as follows.#include using namespace std; void func() { class LocalClass { }; } int main() { return 0; }In the above example, func() is a function and class LocalClass is defined inside the function. So, it is known as a local class.A local class name can only be used in its function and not outside it. Also, the methods of a local class must be defined inside it only. ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
1K+ Views
Abstraction involves providing only the pertinent information to the outside world and hiding the background details. It relies on the separation of interface and implementation for programming.Classes provide abstraction in C++. They provide public methods for the outside world to manipulate data and keep the rest of the class structure to themselves. So the users can use the class as required without knowing how it has been implemented internally.A program to implement abstraction in C++ using classes is given as follows.Example Live Demo#include using namespace std; class Abstraction { private: int length, breadth; public: void setValues(int ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
12K+ Views
rand()The function rand() is used to generate the pseudo random number. It returns an integer value and its range is from 0 to rand_max i.e 32767.Here is the syntax of rand() in C language, int rand(void);Here is an example of rand() in C language, Example Live Demo#include #include int main() { printf("%d", rand()); printf("%d", rand()); return 0; }Output1804289383 846930886srand()The function srand() is used to initialize the generated pseudo random number by rand() function. It does not return anything.Here is the syntax of srand() in C language, void srand(unsigned int number);Here is an example of srand() in C ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
5K+ Views
strdup()The function strdup() is used to duplicate a string. It returns a pointer to null-terminated byte string.Here is the syntax of strdup() in C language, char *strdup(const char *string);Here is an example of strdup() in C language, Example Live Demo#include #include int main() { char *str = "Helloworld"; char *result; result = strdup(str); printf("The string : %s", result); return 0; }OutputThe string : Helloworldstrndup()The function strndup works similar to the function strndup(). This function duplicates the string at most size bytes i.e. the given size in the function. It also returns a pointer to null-terminated ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
6K+ Views
The function fflush(stdin) is used to flush the output buffer of the stream. It returns zero, if successful otherwise, returns EOF and feof error indicator is set.Here is the syntax of fflush(stdin) in C language,int fflush(FILE *stream);Here is an example of fflush(stdin) in C language,Example Live Demo#include #include int main() { char s[20] = "Helloworld"; printf("The string : %s", s); fflush(stdin); return 0; }OutputThe string : Helloworld
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
85 Views
The function ispunct() is used to check that the passing character is a punctuation or not. It returns zero, if it is not a punctuation, otherwise it returns a non-zero value.Here is the syntax of ispunct() in C language, int ispunct(int character);Here is an example of ispunct() in C language, Example Live Demo#include #include int main() { int a = '!'; int b = 'a'; if(ispunct(a)) printf("The character is a punctuation."); else printf("The character is not a punctuation."); if(ispunct(b)) printf("The character is a punctuation."); else printf("The character is not a ... Read More