Expected class, delegate, enumeration, interface, or structure

I am writing a class. I ran into a problem in the title. Here is the code:

class delivery
{
    private string strDeliveryName;
    private string strDeliveryAddress;
    private string strDeliveryDay;
    private string strDeliveryTime;
    private string strDeliveryMeal;
    private string strDeliveryInstructions;
    private string strDeliveryStatus;
}
public delivery(string deliveryName, string deliveryAddress, string deliveryDay, string deliveryTime, string deliveryMeal, string deliveryInstructions, string deliveryStatus)
    {
        strDeliveryName = deliveryName;
        strDeliveryAddress = deliveryAddress;
        strDeliveryDay = deliveryDay;
        strDeliveryTime = deliveryTime;
        strDeliveryMeal = deliveryMeal;
        strDeliveryInstructions = deliveryInstructions;
        strDeliveryStatus = deliveryStatus;
    }

      

I am getting a delivery error, any idea why?

+2


a source to share


5 answers


Your constructor must be in parentheses of the class definition. In an unrelated note, the convention is to use the first letter of the class names.



+14


a source


Your constructor code is not part of the class. Move it inside and everything should be fine. :-)



+2


a source


To answer your second question (in a comment), you need to change the name of the constructor to match the name of the class.

+2


a source


This error occurs because you declared a function outside the class main

. You have to insert the code inside the class main

.

+1


a source


I got this error because I accidentally missed the open figurine in the code above where the error occurred. This meant that the class ended prematurely. So if you get this error, maybe check that the curly braces are correct.

0


a source







All Articles