Skip to content

File Structure

Luke Pring edited this page Mar 15, 2025 · 2 revisions

To ensure modularity and maintainability, SD2-Coursework-VMS is structured into 📁include/ and 📁src/ folders and their corresponding files where code for each section of the code should go. The main.cpp file is in the root directory and ties the program together.

The .hpp files in 📁include/ should contain only declarations, not function implementations.

For example: pets.hpp

#pragma once
#include <string>

class Pet {
private:
    std::string name;
    std::string breed;
    int age;
    ...
public:
    Pet(std::string petName, std::string petBreed, int petAge, ...);
    void displayInfo();
    ...
};

The functions are declared here, but the actual function code should be inside the pets.cpp file in 📁src.

This is how the pets.cpp file could look in comparison:

#include "../include/pets.hpp"
#include <iostream>

// Constructor Implementation
Pet::Pet(std::string petName, std::string petBreed, int petAge, ...) : name(petName), breed(petBreed), age(petAge) ... {}

// Function Implementation
void Pet::displayInfo() {
    std::cout << "Pet Name: " << name << ", Breed: " << breed << ", Age: " << age << " years" << std::endl;
}

Clone this wiki locally