Skip to content
This repository was archived by the owner on Oct 27, 2026. It is now read-only.
Sentimenta1istPublic archive

About

C/C++ OOP practice: own containers, inheritance, templates (2019-2020)

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

SomeOOP

Small C and C++ exercises from an object-oriented programming course: hand-written containers, C string/file utilities, inheritance and templates.

Year: 2019-2020 · Language: C++ and C · Context: university coursework (KPI)

What's inside

Folder What it does
WorkWithMemory_C/ Re-implementation of the glibc argz API in C (argz_create_sep, argz_add, argz_delete, argz_insert, argz_replace, argz_next); test in argztest.c
FilePractice/ Binary "database" of scanners in C: create_db from scanners.csv, add_scanner, del_scanner, per-field index files (make_index, reindex), select by field value
Classes/ cArray, a growable int array (Add, Append, Copy, InsertAt, RemoveAt, FreeExtra, operator[]) with method names modelled on MFC CArray; test in carray_test.cpp
ListImplementation/ List, a singly linked list of int with a std::list-like API (splice, merge, unique, sort, reverse, resize, copy constructor and assignment)
VectorImplementation/ vector, a hand-written dynamic int array with std::vector-like API (assign, erase, insert, sort, unique, capacity)
Inheritance/ Employee database: abstract Person -> Employee -> Manager (holds a list of subordinates), Database loads input.csv, hires/fires, prints departments, simple SQL(field, cond, value) filter
Templates/ List<T> template with a custom iterator (Iterator.h), used for Bus records loaded from park.csv (bus park / route lists, splice, ChangeDriver)

Interesting bits

  • FilePractice/scanner.c stores records as a count header followed by fixed-size SCAN_INFO structs, and builds a separate index per field (make_index) that get_recs_by_index later reads.
  • Inheritance/Manager.cpp implements the copy constructor and operator= for a class holding list<Person*>; Database::ArrangeSubordinates attaches loaded employees to each manager after reading the CSV.
  • Templates/List.h implements splice between two lists, and load() parses ;-separated lines with strtok.
  • VectorImplementation/Vector.h deliberately names its class vector (own file vector.h is included by Vector.cpp), so it shadows the standard name.

Run

Tested with g++/gcc on Linux in a scratch copy, only partly working without edits (the code was written for Visual Studio):

  • ListImplementation: g++ -std=c++14 list.cpp list_test.cpp builds and runs.
  • Templates: g++ -std=c++14 -include cstring -include cstdlib Test.cpp Bus.cpp builds and runs.
  • VectorImplementation: needs a lowercase vector.h on case-sensitive file systems (cp Vector.h vector.h), then g++ Test.cpp Vector.cpp builds and runs.
  • Inheritance: g++ -std=c++14 Database.cpp Employee.cpp Manager.cpp Test.cpp builds, prints the hierarchy, then aborts at the SQL step (not investigated). Run from the folder, it reads input.csv.
  • Classes: does not compile with g++ (new int[double] in carray.cpp).
  • WorkWithMemory_C: argztest.c passes int* where size_t* is expected and segfaults on 64-bit; with that variable changed to size_t all functions print correct results.
  • FilePractice: uses itoa and a function named select that clashes with the POSIX one; with both worked around it builds, creates result.txt and then segfaults. Not re-tested beyond that.

Note

Written in 2019-2020, before AI coding assistants. Kept as-is for history.

About

C/C++ OOP practice: own containers, inheritance, templates (2019-2020)

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages