Do I correctly understand what a class is?

前端 未结 9 861
Happy的楠姐
Happy的楠姐 2021-01-01 20:52

I\'ve had trouble finding a clear, concise laymans definition of a class. Usually, they give general ideas without specifically spelling it out, and I\'m wondering if I\'m u

9条回答
  •  清酒与你
    2021-01-01 21:33

    This is going to be a very simplified explanation. A class is a set of functions and variables and is used to create objects. I think it's good to use real examples instead of dog / bark / talk etc.

    • Class Email
      • Subject (string)
      • Message (string)
      • ToAddress (string)
      • FromAddress (string)
      • Send (function)

    When you call 'new Email()' it creates a new object with those variables and functions. Then you can populate the variables and send it.

提交回复
热议问题