Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Vishwajith-K opened this issue Apr 8, 2021 · 0 comments
Open

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

Vishwajith-K opened this issue Apr 8, 2021 · 0 comments

Comments

@Vishwajith-K
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant