How to create object of the class? Describe few object in detail.
pls answer
no spam answer
Answers
Answered by
1
to create an object of a class you use the class name to declare a variable Example:
class car
{
int carno;
char carname;
}C1;
void main()
{
car C2;
}
Here there are two objects for the class car one is C1 the other is C2 i.e you can declare objects for a class after the class definition (after the closing braces) and anywhere else using the name of the class
NOTE: When you declare a class inside a function or the main it BECOMES LOCAL TO THAT PARTICULAR FUNCTION
class car
{
int carno;
char carname;
}C1;
void main()
{
car C2;
}
Here there are two objects for the class car one is C1 the other is C2 i.e you can declare objects for a class after the class definition (after the closing braces) and anywhere else using the name of the class
NOTE: When you declare a class inside a function or the main it BECOMES LOCAL TO THAT PARTICULAR FUNCTION
Similar questions
Social Sciences,
7 months ago
Environmental Sciences,
7 months ago
Hindi,
7 months ago
Biology,
1 year ago
English,
1 year ago