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 സ്വതവേ private; struct-ന്റെ members സ്വതവേ 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.