chart

CPLUSPLUS classifications and object


objects
image credit:tenouk.com

CPLUSPLUS classifications and object
The main purpose of Object Oriented Programming is to encapsulate the member of the class (variables,methods etc) from direct access. On the other hand, C++ also provide an excellent support for classificaion by means of its conceptual CPLUSPLUS classifications and objects are the backbone of encapsulation and object oriented programming because classes also come under the flag of objects

What is class?

Class consists of member functions and variables and other data types .Classes provides us the flexibility to interact with other classes with the help of modifiers (discussed later)
Here is the development environment

Let’s do something bigger:

#include <iostream>
#include “stdafx.h”

using namespace std;

class Box
{
public:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box
};

int main( )
{
Box Box1; // Declare Box1 of type Box
Box Box2; // Declare Box2 of type Box
double volume = 0.0; // Store the volume of a box here

// box 1 specification
Box1.height = 5.0;
Box1.length = 6.0;
Box1.breadth = 7.0;

// box 2 specification
Box2.height = 10.0;
Box2.length = 12.0;
Box2.breadth = 13.0;
// volume of box 1
volume = Box1.height * Box1.length * Box1.breadth;
cout << "Volume of Box1 : " << volume <

Output


Operators in C++ rewind

imagecredit:wikipedia.org

Syed Adeel Ahmed
Analyst, Programmer, Educationist and Blogger at Technofranchise
Computer Systems Engineer from Sir Syed University Of Engineering & Technology.I am passionate about all types of programming.
Syed Adeel Ahmed on FacebookSyed Adeel Ahmed on GoogleSyed Adeel Ahmed on InstagramSyed Adeel Ahmed on Twitter

Published by

Syed Adeel Ahmed

Computer Systems Engineer from Sir Syed University Of Engineering & Technology.I am passionate about all types of programming.