Appendix A training intern-object-oriented BASICS (1): classes and Instances

Source: Internet
Author: User

An object is a self-contained entity, which is identified by a set of identifiable features and behaviors.

Object-Oriented Programming, object-oriented programming, is actually intended for object programming.

Class is an abstract set of objects with the same attributes and functions.

Note the following during programming:

First, the first letter of the class name should be capitalized. for multiple words, the first letter should be capitalized.

Second, the public modifier must be used to make public.

An instance is a real object.

Instantiation is the process of creating an object. You can use the new keyword to create an object.

The following is an example:

This is a class,

1 using system; 2 using system. collections. generic; 3 using system. text; 4 5 namespace animalgames 6 {7 class Cat 8 {9 Public String shout () 10 {11 return ""; 12} 13} 14}

Call this class,

1 using system; 2 using system. collections. generic; 3 using system. componentmodel; 4 using system. data; 5 using system. drawing; 6 using system. text; 7 using system. windows. forms; 8 9 namespace animalgames10 {11 public partial class form1: form12 {13 public form1 () 14 {15 initializecomponent (); 16} 17 18 private void button#click (Object sender, eventargs e) 19 {20 CAT = new CAT (); // instantiate cat 21 // Note: Cat cat = new CAT (); actually two things are done, 22 // CAT; declare a cat object. The object name is cat23 // cat = new CAT (); instantiate the cat object 24 MessageBox. show (cat. shout (); 25} 26 27} 28}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.