0
Please explain this line ....Vehicle v1 = new Vehicle();
2 Answers
+ 1
Your object v1 is created using the Constructor of Vehicle.
Supposing it is C# :
Your class Vehicle.cs has a constructor (public and name of the class) :
public class Vehicle{
public Vehicle(){
}
public void vroom(){
Console.WriteLine("Vrooom");
}
}
Once your object v1 is created, you can call the different methods in your class Vehicle, per example vroom() by writing v1.vroom();
Classes are used to make your code easier to read. While playing with C#, you will discover the utility. Just enjoy coding. :)
0
tq