Sharp Tutorial
object class in c++

Python

Java

C

C++

HTML/CSS

Java Script

PHP

SQL

C Programs

introduction to c++

  • C++ Home
  • Introduction to C++
  • History features
  • Sample Programs
  • cout , cin , endl
  • Data type and Operators
  • if else in c++
  • loop in c++

Oops in C++

  • Object / Class
  • Constructor
  • Function & Constructor Overloading
  • Inheritance
  • Overriding

Advanced C++

  • Strings in C++
  • Exception Handling
  • Special Functions
  • C++ Programs

Object Oriented in c++

As we know C++ is an object oriented language so everything is surrounded class and object.

Class may defined in many ways like Collection of similar types of elements or we can also say class is the user defined data type

A Class may be create as following

#include<iostream>
using namespace std;
class A
{
public:
int i=10;
void display()
{
cout<<"i here is"<<i;
}
};

Ojbect of the class may be created as following

   A obj;         (classname objectname;)

To run the above class we need to call from main as following

#include<iostream>
using namespace std;
class A
{
public: // access specifier
int i;
void display()
{
cout<<"i here is"<<i;
}
};
int main()
{
A obj;
obj.i=100; // call the class variable with object name
obj.display(); // call the function of A class
return 0;
}

Above program displays the following result

Enquiry about Course

Ask your Question

Click Here

Sharp (2) Tutorials

Video/ C Introduction

Watch video in full size

Video tutorial

Follow by Email
Facebook
Facebook
fb-share-icon
YouTube
Copyright © Sharp Tutorial
Build with WordPress
Wordpress Social Share Plugin powered by Ultimatelysocial
Sharp Tutorial