Hello there, fellow programmers! I am an Aeronautical Engineering student who is doing research on Multidisciplinary Optimization (MDO) since the beginning of this year.
All the code I’ve written so far is in Python, but I want to move it to C so I can learn more about low level programming and so I can have more control over what my code actually does (since it is an MDO code, it needs to be very optimized because every 0.5 seconds added to each iteration add 500 seconds over 1000 iterations (9 minutes!)). I am taking an online course on C from edX, but I still cannot understand how to actually substitute objects for C compliant code. The main problem is that my original code uses lots of objects, and I simply do not know how to eliminate objects from my code.
Can someone help me? Any help is welcomed.
[edit] Thanks for all your answers, I think I’m getting it now.
There are a few approaches to implementing OOP in C. The language doesn’t give you any constructs to implement this out of the box, so it’s up to the developer to do it. Since there is no definite way to do it, let me just give you some examples and you can decide how to use it in your project:
class Parent: def __init__(self): self.__hidden_state = "properties" def __private_method(self): print("private method") def public_method(self): print("public method") @staticmethod def static_method(): print("static method") class Child(Parent): def __init__(self): super().__init__() self.__hidden_state = "child properties"
I would split the C code for this into header and source files:
(header.h)