What is Class and object, How to declare object in c++ oop, Example of class, object and attributes

What is Class and object, How to declare an object in c++ oop, Example of class, object and attributes

In this tutorial, we will learn about the followings;

  1. What is a class?
  2. What is an object?
  3. What are the attributes?
  4. Examples of object and attribute.
  5. How to declare a class?

What is a class?

A class is a big and generalized concept having attributes, functions, and objects.

What is an object?

An object can be any person, thing, place or event, etc.

What is an attribute?

Attributes are the properties of classes.

 

Example of class, object, and attributes:

Class: Furniture

Object: Chair, Table, etc

Attributes: Chair color, Chair price, Table size, etc.

Functions : Add_Table, View_Table, Delete_Table, Update_table etc.

How to declare a class?

Line# Code
1 class furniture
2 {
3 body of the class
4 };

Line 1: Class is keyword and furniture is the class name.

Line 2: Starting body of the class

Line 3: Body of the class where we write the attributes and functions of the class.

Line 4: Ending of the class.

Exercise and Solution Class and object

  1. Write a program class name is hello and display hello world on the screen.
  2. C++ program to display student details using class
  3. Write a program in C to display such a pattern for n number of rows using a number which will start with the number 1 and the first and the last number of each row will be 1.
  4. C++ program to print a hollow square or rectangle star pattern by using the class with the C++ main program.
  5. Write a program in C to display such a pattern for n number of rows using a number which will start with the number 1 and the first and the last number of each row will be 1. 
  6. Write a program in C++ to find the sum of the series 1 +11 + 111 + 1111 + .. n terms.
  7. class objects C++ program pattern like a pyramid repeat.
  8. Classes Objects C++ to display the n terms of odd natural number and their sum.
  9. Classes Objects C++ program to convert a convert decimal number into binary.
  10. Classes and Objects C++ program to find the perfect numbers within a given range.
  11. Classes and Objects C++ program to show the sum of an A.P. series.
  12. Classes Objects C++ program to print the string in reverse order.
  13. 3 Programs in 1.
  14. Classes C+ Program Armstrong number of n digits.
  15. Classes C++ program to display the cube of the number up to a given integer.
  16. class objects C++ program to display patterns like the right angle.
  17. C++ Program to convert a decimal number into binary with Class Objects.
  18. C++ program to find HCF using Class Objects.
  19. Write a program in C++ to display the pattern like a pyramid using an asterisk * and each row contains an odd number of asterisks by using the class objects.
  20. Develop a C++ program to print the rhombus star pattern of N rows using for loop and class objects.
  21. Write a program in C++ to convert a decimal number to hexadecimal using the class objects in object-oriented programming (OOP).
  22. Write a program in C++ to convert a decimal number into octal without using an array using Classes and Objects.
  23. C++ program to display Pascal’s triangle using the class objects.
  24. Class Object C++ program to print hollow rhombus, parallelogram star pattern.
  25. Class Objects C++ program to print mirrored right triangle star pattern.
  26. Class objects C++ Program to convert an octal number into binary.
  27. Class Objects Floyd Triangle C++.
  28. C++ Program to display the sum of the series using classes and objects.
  29. Classes C++ program to find Strong Numbers within a range of numbers.
  30. C++ Inheritance to convert an Octal number to a Decimal number without using an array.
  31. inheritance C++ sum of all integer between 100 and 200 which are divisible by 9.
  32. C++ Inheritance sum of the series 1 +11 + 111 + 1111 + .. n terms.
  33. C++ Inheritance program with classes pyramid pattern numbers increased by 1.
  34. C++ inheritance n terms of odd natural number and their sum.
  35. C++ Program to find the sum of the series x – x^3 + x^5 + Class inheritance.
  36. Inheritance C++ program to print hollow right triangle star pattern.
  37. C++ program Fibonacci series using class inheritance.