У меня есть заголовочный файл, который начинается так:В C, каково минимальное требование для реализации файла заголовка?
typedef struct PriorityQueueStruct PriorityQueue;
/**
* Type definition for an Element.
*/
typedef struct ElementStruct
{
int element;
} Element;
/**
* Type definition for a priority.
*/
typedef struct PriorityStruct
{
int priority;
} Priority;
/**
* Structure for containing the resultant values for a
* call to 'createPriorityQueue'.
*
* 'token' is the identifier for the created data structure
* and is to be used in any call to query or modify it.
* 'resultCode' tells whether the function was successful or not in creating a
* priority queue. 1 for success or an error code describing the failure.
*/
typedef struct InitializationResultStruct
{
PriorityQueue* pq;
int resultCode;
} InitializationResult;
/**
* Structure for containing the resultant values for a
* call to 'peek'.
*
* 'peekedValue' is the first-most value from the priority queue
* 'resultCode' tells whether the function was successful or not in creating a
* priority queue. 1 for success or an error code describing the failure.
*/
typedef struct PeekResultStruct
{
Element element;
Priority priority;
int resultCode;
} PeekResult;
Я немного потерял о том, как реализовать этот файл заголовка в моем простом классе, который является приложением для приоритетной очереди (так называемый TriageQueue). Я оставляю структуры только в файле заголовка? Как я могу реализовать функции (спасибо за подсказку!)? Я ценю любую помощь!
Большое спасибо Джейсону! – Coffee
Идентификаторы, начинающиеся с символа подчеркивания, зарезервированы для реализации в C. Вот почему заголовки системы будут иметь, например, '#ifndef _STDIO_H'. В вашем собственном коде вы должны просто использовать '#ifndef YOUR_HEADER_FILE_NAME_H', без главного подчеркивания. – ataylor
Хорошо, исправлено, спасибо. – Jason