From 48912c9200d86bdcd0d03d7f8beb6c57632e2fdb Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 14 May 2021 09:36:49 +0100 Subject: restyle and also publish ioriot --- content/html/gemfeed/2016-11-20-methods-in-c.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'content/html/gemfeed/2016-11-20-methods-in-c.html') diff --git a/content/html/gemfeed/2016-11-20-methods-in-c.html b/content/html/gemfeed/2016-11-20-methods-in-c.html index c2ae11e4..544ad28f 100644 --- a/content/html/gemfeed/2016-11-20-methods-in-c.html +++ b/content/html/gemfeed/2016-11-20-methods-in-c.html @@ -15,7 +15,7 @@ body { } img { display:block; - max-width: 90%; + max-width: 80%; } p.quote:before { content: " | "; @@ -48,9 +48,8 @@ h2, h3 { -

Written by Paul Buetow 2016-11-20

-Go back to the main site

Methods in C

+

Written by Paul Buetow 2016-11-20

You can do some sort of object oriented programming in the C Programming Language. However, that is very limited. But also very easy and straight forward to use.

Example

Lets have a look at the following sample program. Basically all you have to do is to add a function pointer such as "calculate" to the definition of struct "something_s". Later, during the struct initialization, assign a function address to that function pointer:

@@ -114,5 +113,6 @@ mult.calculate(mult,a,b));

Taking it further

If you want to take it further type "Object-Oriented Programming with ANSI-C" into your favorite internet search engine, you will find some crazy stuff. Some go as far as writing a C preprocessor in AWK, which takes some object oriented pseudo-C and transforms it to plain C so that the C compiler can compile it to machine code. This is actually similar to how the C++ language had its origins.

E-Mail me your thoughts at comments@mx.buetow.org!

+Go back to the main site
-- cgit v1.2.3