Lesson 15 of 24

Classes మరియు Objects

10 min 30 XP

Class అనేది data members, member functions ఉన్న నమూనా. private members ను 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 members default గా private; struct members default గా public. C++ లో వీటి మధ్య తేడా ఇదొక్కటే.

Challenge

+30 XP

private length, width మరియు public set(int l, int w), area(), perimeter(), isSquare() ఉన్న class Rectangle రాయండి. 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.