c++ - Undefined reference Linker error to a variable already in the same file -


I am making the code for linked lists and when I try to compile with G ++, Getting a strange error.

  /cygdrive/c/Users/Blas/AppData/Local/Temp/ccEcixjp.o: In function `node ': /cygdrive/c/Users/Blas/Documents/blas.borde/ Trunk / cs170 / lab6 / list.h: 50: 'CS170 :: ListLab :: node :: node_elive' /cygdrive/c/Users/Blas/Documents/blas.borde/trunk/Cs170/Lab6/List.h Undefined Reference: 50: 'undefined reference to' CS170 :: ListLab :: node :: node_elive '/cygdrive/c/Users/Blas/Documents/blas.borde/trunk/Cs170/Lab6/List.h.5 Undefined reference:: ListLab :: ~ Node :: nodes_alive ' 

And this is my code

  named place CS 170 {namespace listlab {struct node { Int number; // data part node * next; // Fixed int node_live for the next node in the indicator list; // The number of nodes is still / around / non-default constructor node (int value) {number = value; Next = 0; Nodes_alive ++; // a node was created} // destroyer ~ node () {nodes_alive--; // one node was destroyed}}; The strange thing is that I'm already defining node_alive, so I do not know that the linker says that the variable is not defined. Perhaps something is clear that I am missing. Please, I need help.   

It seems that you have only declared static data member node_live in class definition, it is defined outside of orbit In some modules in the global namespace

  int CS170 :: ListLab :: Node :: nodes_alive;  

or

  Namespace CS 170 {Namespace list label {int node :: node_alive; }}  

Although it will be initially initialized from zero, you can explicitly specify as the initiator in your definition.


Comments

Popular posts from this blog

Removing From ArrayList, In Loop Based On It's Size, But Breaking After Remove Still Gives OutOfBounds -

c# - Reactive Extensions ControlScheduler -

java - Add color code support to a Bukkit plugin -