C/C++

Prototyping in C++

Submitted by Yorkiebar on
Introduction: This tutorial is on how to use Function Prototyping in C/C++. Function File: Here is a basic function file which, after running the 'int main' function, runs a custom function named 'calculate' which returns an integer and is output to the screen.
  1. #include <iostream>

Inheritance in C++

Submitted by moazkhan on

Inheritance in C++

In this tutorial you will learn: 1. What is inheritance? 2. What are different types of inheritance? 3. Why to use inheritance? 4. C++ syntax What is inheritance? A form of software reuse in which you create a class that absorbs an existing class’s data and behavior and enhances them with new capabilities.

Arrays as Class Data Member

Submitted by moazkhan on

Arrays as Class Data Member

In this tutorial you will learn: 1. How to make Arrays as Class Data Member? 2. Why to use arrays as attributes of the class? 3. How to make array of objects? 4. C++ syntax Arrays can also be the data members of the class, just like integer, float and other data type integers we can also define an array as the data members. Arrays are used as data members because if the user requires that the object contain a lot of information which is to be saved in the array then he will use array as the data member of the class.

Constant Data Members and Objects

Submitted by moazkhan on

Constant Data Members and Objects

In this tutorial you will learn: 1. What are Constant Data Members? 2. What are Constant Objects? 3. Why to use Constant Data Members and Objects? 4. How to use Constant Data Members and Objects? 5. C++ syntax What are Constant Data Members? The data members that are once initialized and can never be changed are called constant member functions. Constant member functions are just like normal data members, only ‘const’ key word is added before writing the data type of the data member of the class.

Static Data Members in C++

Submitted by moazkhan on

Static Data Members

In this tutorial you will learn: 1. What are Static Data Members? 2. Why to use Static Data Members? 3. How to use Static Data Members in program? 4. Basic C++ syntax What are Static Data Members? Static members are those data members that retain their value , whenever the static member is reused in the program. Static data members store the latest value in them so that the value will be used for next time when the function that makes use of static data member is called.

Returning Objects from Function in C++

Submitted by moazkhan on
Returning Objects from Function in C++ In this tutorial you will learn: 1. How to pass an object in a function argument 2. How to return an object from a function 3. How to write functions outside class 4. Basic C++ syntax In C++ when we need to return a variable from a function we have to write its return type before the name of function and arguments.

Constructors and Destructors in C++

Submitted by moazkhan on

Constructors and Destructors in C++

In this tutorial you will learn: 1. What are Constructors? 2. What are Destructors? 3. To use constructors and destructor in programs 4. Basic C++ syntax What are constructors? Whenever an object of a certain class is made, the data member of the objects are be initialized to some value and this purpose is achieved by using special function called constructors.

Setter and Getter functions in C++

Submitted by moazkhan on

Setter and Getter functions in C++

In this part you will learn: 1. How to make an object of class in C++ 2. What are Setters 3. What are getters 4. To use setters and getters 5. Basic C++ syntax How to make an object of class in C++? Whenever we want to make an object of the class we first define its class and then in the main of the program we write name of the class followed by the name of the object we want to make. e.g to make an object we write the code as class anyclass{ //data members and functions }; int main { anyclass myobj; } In the above code we have

Introduction to Object Oriented Programming in C++

Submitted by moazkhan on

Introduction to Object Oriented Programming in C++

In this part you will learn: 1. Why using Object Oriented programming approach? 2. What are Classes 3. Why we use classes 4. What are Access specifiers 5. Basic C++ syntax Why we use Object Oriented programming approach? We use object oriented programming in C++ because the procedural language( language containing all the functions and variables within the main of the program) cannot cope with very large projects like when we have to use several hundred of functions within one program.