Functions Declarations
Syntax
PrefixFunctionQualifier ReturnType Identifier(Args...) SuffixFunctionQualifier { /*function body*/ }
The qualifiers are optional.
Prefix Qualifiers
Placed before the return type.
| Qualifier | Description |
|---|---|
| inline | Hint for inlining |
| noreturn | Function never returns |
| discardable | Return value may be ignored |
| deprecated | Marked for removal |
| virtual | Enables runtime polymorphism |
Suffix Qualifiers
Placed after the parameter list.
| Qualifier | Description |
|---|---|
| abstract | Pure virtual (no implementation) |
| override | Overrides base class method |
| final | Prevents further override |
| const | Non-mutating method |
| throws | May throw exceptions |
Examples
// free function
inline int32 computeSum(int32 a, int32 b) { return a + b; }
// non-returning function
noreturn void terminate() { /* exits program */ }
// discardable return
discardable int32 tryParse(ascii* str) { /* ... */ }
// deprecated function
deprecated("use newMethod instead") void oldMethod() { /* ... */ }
// virtual method
virtual void update() { /* ... */ }
// pure virtual method
virtual void draw() abstract;
// override with const
virtual int32 getCount() const override { return _count; }
// final override that throws
virtual void process() override final throws { /* ... */ }