There are times when a value needs to be shared. My solution was to create a new class in the project then use that class in all instances that would like to utilize that value.
The first file would be the header.
[codesyntax lang=”cpp”]
#ifndef SD01_H #define SD01_H class sd01 { public: sd01(); virtual ~sd01(); bool doPdf; protected: private: }; #endif // SD01_H
[/codesyntax]
That would be followed by the associated “cpp” file.
[codesyntax lang=”cpp”]
#include "sd01.h" sd01::sd01() { //ctor } sd01::~sd01() { //dtor }
[/codesyntax]
To gain access to the class make sure to use the include statement for the header file.
[codesyntax lang=”cpp”]
#include "sd01.h"
[/codesyntax]
To gain access to the file code something like this.
[codesyntax lang=”cpp”]
sd01 sd;
[/codesyntax]
To test the variable code something like this.
[codesyntax lang=”cpp”]
if (sd.doPdf == true) { myParentFolder = _T("/home/archman/Documents/"); cnt = dir.GetAllFiles(myParentFolder, allFileSpecifications, _T("*.pdf")); }
[/codesyntax]
Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.