cangjie-class

Explain Cangjie class definitions, inheritance, and property management.

1|Updated Mar 14, 2026
One-click install
npx skills add https://github.com/SunriseSummer/CangjieDocValidator --skill cangjie-class
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cangjie-class
Source: https://github.com/SunriseSummer/CangjieDocValidator/tree/main/.github/skills/class
Command: npx skills add https://github.com/SunriseSummer/CangjieDocValidator --skill cangjie-class

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers understand and implement complex object-oriented programming concepts within the Cangjie language, from basic class definitions to advanced inheritance and property management.

Core Features & Use Cases

  • Class Definition: Learn syntax for classes, abstract classes, and sealed classes.
  • Constructors & Destructors: Understand init, main constructors, and ~init finalizers.
  • Inheritance & Polymorphism: Grasp single inheritance, override, and redef.
  • Properties & Access Modifiers: Master prop, mut prop, and access levels (private, internal, protected, public).
  • Use Case: Implement a robust PaymentGateway interface with concrete implementations like AliPay, ensuring proper encapsulation and inheritance.

Quick Start

Explain how to define a simple class named Dog with a name property and a bark method.

Frequently Asked Questions about cangjie-class

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define a class in Cangjie with member variables and methods?

To define a class in Cangjie, use the class keyword and specify member variables, member functions, and properties. You can create objects from these definitions and manage encapsulation using access modifiers like private, internal, protected, and public.

How does inheritance work in Cangjie programming?

Cangjie supports single inheritance, allowing subclasses to inherit from one parent class. You use the override keyword to redefine inherited member functions and the redef keyword for other member redefinitions to achieve polymorphism.

What is the syntax for constructors and finalizers in Cangjie?

Cangjie uses the init keyword for constructors, including main constructors, to initialize class instances. Finalizers use the ~init syntax to clean up resources before object destruction.

Can I use abstract and sealed classes in Cangjie?

Yes, Cangjie supports abstract classes and sealed abstract classes. Abstract classes define base structures, while sealed classes restrict inheritance hierarchies, ensuring controlled object creation and usage patterns.

How do properties and access modifiers manage encapsulation in Cangjie?

Cangjie uses prop and mut prop keywords to define class properties. Access modifiers like private, internal, protected, and public control visibility, ensuring proper encapsulation of member variables and functions within your object-oriented design.