Computer Science, asked by S1127, 1 year ago

How to create object of the class? Describe few object in detail.
pls answer
no spam answer

Answers

Answered by nhanif
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

Similar questions