Lesson 15 of 24

Classes மற்றும் Objects

10 min 30 XP

Class ஒரு வரைபடம்: data members மற்றும் member functions. private உறுப்புகளை class-க்கு வெளியே அணுக முடியாது (encapsulation); public methods மூலம் மட்டும்.

Example: edit me and press Run

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.

class-ல் உறுப்புகள் இயல்பாக private; struct-ல் இயல்பாக public. இதுதான் C++-ல் class vs struct-ன் ஒரே வேறுபாடு.

Challenge

+30 XP

Rectangle class எழுதுங்கள்: private length, width; public set(int l, int w), area(), perimeter(), isSquare(). main()-ல் l, w படித்து print செய்யுங்கள்: Input: 4 4 Output: Area: 16 Perimeter: 16 Square: yes

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.