IEO Level 2- English Olympiad (SOF) Class 9 Coaching Programs
⏳ 🎯 Online Tests (2 Tests [50 Questions Each]): NTA Pattern, Analytics & Explanations
Click Here to View & Get Complete Material
Rs. 200.00
3 Year Validity (Multiple Devices)
🎓 Study Material (303 Notes): 2024-2025 Syllabus
Click Here to View & Get Complete Material
Rs. 450.00
3 Year Validity (Multiple Devices)
🎯 250 MCQs (& PYQs) with Full Explanations (2024-2025 Exam)
Click Here to View & Get Complete Material
Rs. 200.00
3 Year Validity (Multiple Devices)
Classes and Objects with Constructors⟋Destructors: Creating Objects
Example 1
# include <iostream.h >
class student
{
private :
char name [ 80 ];
int rn ;
float marks ;
private :
void getdata ( ) ;
void putdata ( ) ;
};
void student :: getdata ( )
{
cin ≫ name ≫rn ≫ marks ;
}
void student :: putdata ( )
{
cout ≪ name ≪ rn ≪ marks ;
}
void main ( )
{
student st ;
st. getdata ( ) ;
st. putdata ( ) ;
}
Creating Objects
- An object is an instance of a class and it can be created by using class name. student st; Object can be created.
- When a class is defined by placing their names immediately after the closing brace.
class student
{
} x, y, z ;
</chart>
The above definition would create the object x, y and z of type student.