Interface, virtual, and abstract in C,

Source: Internet
Author: User

Interface, virtual, and abstract in C,

Abstract:

The abstract method must be declared in the abstarct class, without default implementation, and must be implemented by subclass.

Virtual:

The virtual method can be declared in the abstract class or non-abstarct class, and can be implemented by default.

Iii. Interface)

Interface Description

1. The interface is a reference type, and multiple inheritance can be implemented through the interface.
The interfaces in 2.c # cannot contain modifiers such as new, public, protected, internal, and private.
3. only "abstract" members can be declared in the interface (so the interface cannot be instantiated directly next (that is, the instance object of an interface cannot be declared using the new operator )), you cannot declare a shared domain or private member variable.
4. The interface declaration does not include data members. It can only contain methods, attributes, events, indexes, and other Members.
5. The access level of the interface members is the default value (the default value is public). Therefore, you cannot specify any access modifiers other than public when declaring the interface members. Otherwise, the compiler reports an error.
6. The interface members cannot have static, abstract, override, and virtual modifiers. If you use the new modifier, no error is reported, but a warning is given that no keyword new is required.
7. When declaring an interface member, you are not allowed to write specific executable code for the interface member. That is to say, you only need to specify the name and parameter of the interface member when declaring the interface.
8. Once an interface is inherited, The subclass needs to instantiate all the members of the interface (perform operations on abstract members of the interface through specific executable code ).

(Baidu Encyclopedia: http://baike.baidu.com/link? Url = UlmCxkt6O7lqmGK4IdM5CmzwhK3nnEQmA3dCkh9I6-noq3GfVv-chDLIo3QMQYPlEo3Vv8PK8J2e9OidgP8Sta)

Meaning of interfaces

1. A common usage of an interface is to declare a group of behavior methods. This group of behavior methods can have different implementations and multiple implementations. The classes that use this group of behavior only care about the declaration of behavior. Simply put, an interactive contract is defined.

2. Interface-oriented programming. It is easy to layer the application system and interfaces are used for interaction between different layers. This has the following benefits: Clear levels of responsibility; easy UT; easy decoupling (DI, IoC ).

3. Multi-inheritance can be implemented.

 


Symbol in C Language <Yes

Left shift operator (<)

Removes all the binary bits of an operation object from the left and adds 0 to the right ).

For example, a = a <2 shifts the binary bits of a two places to the left and complements 0 to the right,

Move 1 to the left and then a = a * 2;

If the left shift does not include 1 in the Discard high position, then shifts one bit left, which is equivalent to multiplying the number by 2.
Shift right operator (>)

Shifts all the binary bits of a number to several places to the right, and adds 0 to the left of the positive number, 1 to the left of the negative number, and discards the right of the negative number.

The operand shifts one digit to the right, which is equivalent to dividing the number by 2.

For example, a = a> 2 shifts the binary bit of a two places to the right,

0 or 1 to see whether the number is positive or negative.

Symbol in C Language <Yes

Left shift operator (<)

Removes all the binary bits of an operation object from the left and adds 0 to the right ).

For example, a = a <2 shifts the binary bits of a two places to the left and complements 0 to the right,

Move 1 to the left and then a = a * 2;

If the left shift does not include 1 in the Discard high position, then shifts one bit left, which is equivalent to multiplying the number by 2.
Shift right operator (>)

Shifts all the binary bits of a number to several places to the right, and adds 0 to the left of the positive number, 1 to the left of the negative number, and discards the right of the negative number.

The operand shifts one digit to the right, which is equivalent to dividing the number by 2.

For example, a = a> 2 shifts the binary bit of a two places to the right,

0 or 1 to see whether the number is positive or negative.

Related Article

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: info-contact@alibabacloud.com 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.