linker-errors

linking error : multiple definition of static variable

邮差的信 提交于 2021-01-01 04:58:31
问题 So I wrote the following code first and was getting a compile error. After reading this answer : static array class variable "multiple definition" C++ I modified my code and moved the static variable definition to a cpp file and it executes fine, but I'm unable to understand that when I have used pre-processor guards, why is it showing multiple definition error ? #ifndef GRAPH_H #define GRAPH_H #include<iostream> #include<vector> using namespace std; struct node{ int element=0; static vector