Ah yes- that does sound exactly like what I am doing. Especially considering the language I used the most before C++ was C#!
The code snippit you posted is also what I am doing.
Here are some code samples:
1 2 3 4 5 6 7 8 9 10
|
int main()
{
//Initialization and Loading
YearRecord *AllRecords;
AllRecords = new YearRecord(2011);
LoadDatabase(AllRecords);
LoadTodaysDate();
...
}
|
The basic premise is to represent each day of the year through a combination of arrays and a linked list called YearRecord: each member of the list represents one year, and contains a 12x31 array to hold the actual data being stored. So essentially, each day of the year gets its own data storage space in memory, and also when stored in a .txt .
The two functions called belong to two separate files, but they aren't actually classes. For instance, to use LoadDatabase(), I included a header...
|
#include "DatabaseManager.h"
|
The header (DatabaseManager.h) contains function prototypes for the two functions in the file DatabaseManager.cpp:
1 2 3 4 5 6 7 8 9
|
#ifndef DATABASEMANAGER_H
#define DATABASEMANAGER_H
#include "YearRecord.h"
void LoadDatabase(YearRecord*);
void SaveDatabase(YearRecord*);
#endif
|
and then the function itself is detailed in the file DatabaseManager.cpp, with an include to its own header.
From what I was taught, doing this allowed me to include the header of any file I wished to call functions from, and then the compiler (or linker?) would figure out the details from the file fleshing out the header's function declarations.
It seems, that this would be similar to making DatabaseManager a class, getting an object instance of it in main.cpp, and then calling functions from there. But instead, I am using the header include as my "instance" from which to call functions. OOP imitation is probably an excellent diagnosis.
So from what I gather, in order to better employ good C++ OOP, I need to make each of my .cpp files into classes so that they can have object instances.