Драствуйте!
Есть вот такая штук. Есть три файла: test.h, test.cpp, test2.cpp
В test.h объявлена переменная. Нужна, чтобы она была и видна и изменялась в обоих срр-шниках.
Делаю так вот:
test.h
#pragma once
#include "stdafx.h"
static int AAA = 0;
void GetA1 ();
static void GetA2 ()
{
int a = AAA; // ААА = 10. Нормально, если после test.cpp. Хотелось бы 20? как в test2.cpp
AAA = 30;
}
test.cpp
#pragma once
#include "stdafx.h"
#include "test.h"
//extern int AAA;
int _tmain(int argc, _TCHAR* argv[])
{
AAA = 10;
GetA1 (); // ААА = 10. А нужно 20 !
GetA2 (); // ААА = 30. Нормально
return 0;
}
test2.cpp
#pragma once
#include "stdafx.h"
#include "test.h"
//extern int AAA;
void GetA1 ()
{
int a = AAA; // a = 0. А нужно 10 !
AAA = 20;
}
Подскажи плз, как это правильно описывть?
extern'ы нифиг не помогают
Надеюсь, правильно объяснил