I have the follwing class defined in X.cpp
class X {
public:
static bool bl_PropFile;
void static writeToFile() {
if(bl_PropFile == true) {
// do something
} else if(bl_PropFile == false) {
// do something
}
}
};
bool MonitorCode::bl_PropFile;
Then I have another file called Y.cpp as shown below:
#include <iostream>
#include<stdio.h>
#include "X.cpp"
void main(void) {
// I call the static method of X here
X::writeToFile();
}
both the files are compiling fine. But when I am building
them I am getting the following error:
X.obj : error LNK2005: "public: static bool X::bl_PropFile" (?bl_PropFile@X@@2_NA) already defined in Log.obj
What cab be the problem?
class X {
public:
static bool bl_PropFile;
void static writeToFile() {
if(bl_PropFile == true) {
// do something
} else if(bl_PropFile == false) {
// do something
}
}
};
bool MonitorCode::bl_PropFile;
Then I have another file called Y.cpp as shown below:
#include <iostream>
#include<stdio.h>
#include "X.cpp"
void main(void) {
// I call the static method of X here
X::writeToFile();
}
both the files are compiling fine. But when I am building
them I am getting the following error:
X.obj : error LNK2005: "public: static bool X::bl_PropFile" (?bl_PropFile@X@@2_NA) already defined in Log.obj
What cab be the problem?