How do I access a variable found in another class in a different file.
This is my attempt but it does not compile. Might have some syntax error. Just need the logic. Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13
Test.h
#ifndef TEST_H
#define TEST_H
class Test
{
public:
Test();
virtual ~Test();
//create a static variable e.g. static int var;
staticint var;
};
#endif /*TEST_H*/
CLA.cpp
#include "CLA.h"
#include <iostream>
#include <Test.h>
CLA::CLA(){}
CLA::~CLA{}
CLA::join(){
Test jn;
std::cout << Test.var << std::endl; //Does not compile
// I need this Test.var to be 1
}
1 2 3 4 5 6
main.cpp
#include <Test.h>
int main(){
Test pt;
pt.var = 1;
}