{"id":18813681,"url":"https://github.com/iabdullah215/cpp-separation-of-interface","last_synced_at":"2025-10-10T05:09:13.687Z","repository":{"id":175609461,"uuid":"654198089","full_name":"iabdullah215/cpp-separation-of-interface","owner":"iabdullah215","description":"Example code for separation of interface in C++.","archived":false,"fork":false,"pushed_at":"2024-05-28T18:34:30.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-09T23:42:41.302Z","etag":null,"topics":["cpp","interface","separation-of-interface"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iabdullah215.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-15T15:35:10.000Z","updated_at":"2024-05-28T18:36:01.000Z","dependencies_parsed_at":"2023-11-29T07:23:32.159Z","dependency_job_id":"0dcde7e4-3352-4660-9270-28c42ed27737","html_url":"https://github.com/iabdullah215/cpp-separation-of-interface","commit_stats":null,"previous_names":["iabdullah215/teacher-portal","iabdullah215/cpp-separation-of-interface"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iabdullah215/cpp-separation-of-interface","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iabdullah215%2Fcpp-separation-of-interface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iabdullah215%2Fcpp-separation-of-interface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iabdullah215%2Fcpp-separation-of-interface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iabdullah215%2Fcpp-separation-of-interface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iabdullah215","download_url":"https://codeload.github.com/iabdullah215/cpp-separation-of-interface/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iabdullah215%2Fcpp-separation-of-interface/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002789,"owners_count":26083468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","interface","separation-of-interface"],"created_at":"2024-11-07T23:38:12.937Z","updated_at":"2025-10-10T05:09:13.655Z","avatar_url":"https://github.com/iabdullah215.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cpp Separation Of Interface\n\nThe practice of organizing `C++` code into separate header files, implementation files, and main files is commonly referred to as separation of interface and implementation. This concept is a fundamental aspect of modular programming and software engineering, aiming to improve code maintainability, readability, and reusability.\n\n## Key Terminology\n\n**Header File (.h or .hpp):** Contains declarations of functions, classes, and variables. It defines the interface that other parts of the program can use.\n\n**Source File (.cpp):** Contains definitions of the functions and classes declared in the header files. This is where the actual implementation of the declared functionalities is written.\n\n**Main File (main.cpp):** Contains the main function, which is the entry point of the program. It typically uses the functions and classes defined in other source files.\n\n## Specific Names and Concepts\n\n**Declaration:** The process of specifying the interface of functions and classes. Declarations are typically placed in header files.\n\n```cpp\n// header.h\nvoid sayHello();\nclass Greeter {\npublic:\n    void greet();\n};\n```\n\n**Definition:** The process of providing the actual implementation of the declared functions and classes. Definitions are placed in source files.\n\n```cpp\n// implementation.cpp\n#include \"header.h\"\n#include \u003ciostream\u003e\n\nvoid sayHello() {\n    std::cout \u003c\u003c \"Hello, World!\" \u003c\u003c std::endl;\n}\n\nvoid Greeter::greet() {\n    std::cout \u003c\u003c \"Greetings!\" \u003c\u003c std::endl;\n}\n```\n\n**Include Guards:** Preprocessor directives used in header files to prevent multiple inclusions of the same file, which can cause compilation errors.\n\n```cpp\n// header.h\n#ifndef HEADER_H\n#define HEADER_H\n\n// Declarations\n\n#endif // HEADER_H\n```\n\n**Compilation:** The process of converting source code into object code. Each source file is compiled separately into an object file (.o or .obj).\n\n```console\ng++ -c main.cpp\ng++ -c implementation.cpp\n```\n\n**Linking:** The process of combining object files into a single executable. The linker resolves references between the object files.\n\n```console\ng++ -o myprogram main.o implementation.o\n```\n\n**Makefile:** A file used by the make build automation tool to compile and link programs. It defines rules for building targets.\n\n```jsx\n# Makefile\n\nCXX = g++\nCXXFLAGS = -Wall -std=c++11\nTARGET = myprogram\nSRCS = main.cpp implementation.cpp\nOBJS = $(SRCS:.cpp=.o)\n\nall: $(TARGET)\n\n$(TARGET): $(OBJS)\n\t$(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJS)\n\n%.o: %.cpp\n\t$(CXX) $(CXXFLAGS) -c $\u003c -o $@\n\nclean:\n\trm -f $(OBJS) $(TARGET)\n```\n\nBy following this methodology, you ensure a clear separation between the interface and implementation, which enhances the modularity and maintainability of your code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiabdullah215%2Fcpp-separation-of-interface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiabdullah215%2Fcpp-separation-of-interface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiabdullah215%2Fcpp-separation-of-interface/lists"}