[英]Usage of Global variables in C++
我正在開發一個從輸入目錄中讀取文件,對其進行處理並將其加載到DB的應用程序。 Filelist和CurrentFile這兩個類是應用程序的一部分。 類的定義如下。
class Filelist
{
//list of files
list of files;
// pointer to the current file
CurrentFile *ptr
};
class CurrentFile
{
vector<list of records>
methods to process the records
..
..
};
我必須添加另一個審計結構,以跟蹤成功處理的記錄和錯誤的記錄。 處理完所有文件后,此審核結構將加載到數據庫中。
struct Recaudit
{
//record to keep track of
//Various counts
int successcnt;
int errorcnt;
billedcnt;
some other counts related to the records
};
該審核記錄具有跨CurrentFile多種方法設置的數據集。
是否可以將此審核記錄設為CurrentFile的成員變量(或應該將其聲明為靜態全局變量)?
我想,審計是某種日志? 您必須對其目的做出決定。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.