how do i make it so that functions and procedures that are located in other files in the include statement have access to the global variables within main.cpp, thanks in advance.

how do i make it so that functions and procedures that are located in other files in the include statement have access to the global variables within main.cpp, thanks in advance.

As usually:
main.cpp:

...
bool troublesWanted = true;
bool IlikeBadDesign = true;
...
int main()
{ ... }
void Nil() {}

globals.h:

#ifndef GLOBALS_H
#define GLOBALS_H
extern bool troublesWanted;
extern bool IlikeBadDesign;
void Nil();
#endif

another.cpp:

...
#include "globals.h"
void Void()
{
    if (!troublesWanted)
        IlikeBadDesign = false;
    else
        Nil();
}

;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.