Skip to content

Is it possible to achieve encapsulation/abstraction in C? #3

@Vishwajith-K

Description

@Vishwajith-K

Yes. But may not be achievable in single file. If an identifier is used, it must first be declared/defined earlier. That's not the case with typedef. A type can be aliased to another type even if the first type (that is being aliased) doesn't exist earlier. Compilation succeeds, except some kind of clarification may be needed to run the code. This usage yields opaqueness for a given type. And limits user to use the provided abstraction layer (typically getter, setter) and not the underlying data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions