Stay Tuned!

Subscribe to our newsletter to get our newest articles instantly!

C++ Programming

C++ – Class and Object With Syntax

Class and Object With Syntax

C++ – Class

A class is a collection of objects of similar type which have same property and common behavior.

For example, roll, name, age, are the member of class student and pigeon, sparrow, crow, etc are the object of the class bird. A class is a user-defined data type that holds both data and functions.

The internal data of class is called data member and functions are called member functions. The member functions mostly manipulate the internal data of a class.

Read: Introduction to OOP

C++ Code

class class_name{
variable declaration;
function declaration;
variable declaration;
function declaration;
class student{
int roll;
char name[20];
int age;
void getdata();
void displaydata();

C++ – Object

The object is the combination of data and functions in a single unit. The object can interact without having to know details of each other’s data or code.

It is sufficient to know the type of message accepted and the type of response returned by the objects.

Example, automobiles are an object as they have size, weight, color etc. as attributes data, and starting, turning the wheel, processing, accelerator pedal etc. as operation.

C++ Syntax

object: employee


About Author provides tutorials related to tech and programmings. We are also setting up a community for the users and students.

You may also like

program to find leap year
C++ Programming

C++ Program to Find Leap Year by Using Function

  • March 3, 2016
Write a program to find if the inputted year is a leap year or not by using the concept of