Tải bản đầy đủ (.pdf) (2 trang)

Chapter 12 Quick Reference

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (7.46 KB, 2 trang )



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()
{
...
}
}




Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×