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.