Chapter 12 Quick Reference

2 330 0
Chapter 12 Quick Reference

Đang tải... (xem toàn văn)

Thông tin tài liệu

Chapter 12 Quick Reference To Do this Create a derived class from a base class Declare the new class name followed by a colon and the name of the base class. For example: class Derived : Base { . } Call a base class constructor Supply a constructor parameter list before the body of the derived class constructor. For example: class Derived : Base { . public Derived(int x) : Base(x) { . } . } Declare a virtual method Use the virtual keyword when declaring the method. For example: class Mammal { public virtual void Breathe() { . } . } Declare an interface Use the interface keyword. For example: interface IDemo { string Name(); string Description(); } Implement an interface Declare a class using the same syntax as class inheritance, and then To Do this implement all the member functions of the interface. For example: class Test : IDemo { public string IDemo.Name() { . } public string IDemo.Description() { . } } . Chapter 12 Quick Reference To Do this Create a derived class from a base class Declare

Ngày đăng: 28/10/2013, 20:15

Tài liệu cùng người dùng

Tài liệu liên quan