Menu
Coddy logo textTech

Project Setup

Part of the Object Oriented Programming section of Coddy's C journey — lesson 22 of 61.

challenge icon

Challenge

Easy

Let's begin building your Bank Account library! In this first step, you'll create the public interface—the header file that defines what operations exist without revealing any implementation details.

You'll create two files to set up the project foundation:

  • account.h: Your public header file. This is what users of your library will include. Declare an opaque Account type using an incomplete type declaration—no struct body, just a forward declaration that tells the compiler the type exists. Then declare the function prototypes for create_account (takes an integer for the account ID and returns an Account pointer) and destroy_account (takes an Account pointer and returns nothing). Don't forget include guards using the symbol ACCOUNT_H.
  • main.c: A simple test file to verify your header compiles correctly. Include your header and print a message confirming the interface is ready. Since we haven't implemented the functions yet, just print a confirmation message—the actual implementation comes in the next lesson.

The key insight here is that your header reveals what the Account module can do (create and destroy accounts) without showing how it stores data internally. Anyone including account.h will know an Account type exists and what functions are available, but they won't be able to access any internal fields—because you haven't defined any in the header!

Your main file should output:

Account interface ready

This sets the stage for the complete Bank Account system you'll build over the next several lessons. The header you create now will grow to include deposit, withdraw, and get_balance as you progress through the project.

Try it yourself

#include <stdio.h>
#include "account.h"

int main() {
    // TODO: Print a message confirming the interface is ready
    // The message should be: "Account interface ready"
    
    return 0;
}

All lessons in Object Oriented Programming