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

Buy advertisement space on T4Tutorials

For more details email [email protected]