C++ Class




C++ Class and Objects




C++ is an object oriented programming language so it use class
to binding data members and member function (function that use in the class) in a single program.


Definition of class:-

                               Class is a user define data type and it binding the data and function in single unit and give more security by access specifires that can be public private and protected

(We discuss in next blog)

When you define a class, you define a blueprint for a data type. This doesn't actually define any data, but it does define what the class name means, that is, what an object of the class will consist of and what operations can be performed on such an object.

To define a class we using the Class keywords to define the class after that we give class name that can give by you (because class in a user define data type) to start programming in this class we use open and close curly braces “{}” in this curly braces we define access specifier to secure the data by third person after that we declare the member function. In the end of the close braces we use semicolon to end the class.

#include <iostream.h>
#include <conio.h>
Class simple           //Class keyword and class name
{                                 
Public:                          // access specifier
Int x;                           
Void display()             //Class function
        {
              Cin >>”enter the value of x”>>x;
             Cout<<”value of x is”<<x;
         }
};                               
Void main()            //main function
{
simple  s1;                  //creating an object (s1)
s1.display()                 //call a class function by object
}
After the end of class we create main function to create an object to call the member function and data member of class.





To learn more you can just click the below topics:

C++

INTRODUCTION OF C++ || Definition of C++
Brief history of C++ || history of C++
Features of C++ || why we use C++ || concept of C++
Concept of OOP || What is OOP || Object oriented programming language
Difference Between OOP And POP || Different Between C and C++
Characteristics of C++
Interesting fact about C++ || Top 10 interesting fact about C++
C++ Program Structure
Writing first program in C++ || how to write hello world in C++
Basic Data Type And Variable In C++
Identifier in C++
Keywords in C++
Token in C++
Comment in C++
Constant in C++
Modifier in C++
Taking User Input in C++ | User input in C++
Input Output Operator In C++
C++ Operators | Operator in programming language
How to Add two number in C++
Polymorphism in C++
Compile Time Polymorphism in C++
Function overloading in C++
Operator Overloading in C++
What are Control Structures in C++ || Understanding Control Structures in C++ | How to use if, else, switch
What are Functions and Recursion in C++ | How to Defining and Calling Functions

Object in C++

Data Science

The History and Evolution of Data Science
Scope of Data Science
Why learn Data Science? | Why Data Science?
Impact of Data Science
The Importance of Data in Science | Introduction to Data Science
What is Data Analysis | Data Analyst for Beginners

Algorithm

Why algorithm | The Importance of Algorithms in Modern Technology

Tech to know

Which is better | BSc in Computer Science or BTech?

Post a Comment

Ask any query by comments

Previous Post Next Post