home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16599 < prev    next >
Encoding:
Text File  |  1992-11-19  |  3.8 KB  |  140 lines

  1. Path: sparky!uunet!ogicse!clark!frank
  2. From: frank@clark.edu (Frank Torres)
  3. Newsgroups: comp.lang.c++
  4. Subject: What's wrong with compiler's or program
  5. Message-ID: <1992Nov19.225912.11004@clark.edu>
  6. Date: 19 Nov 92 22:59:12 GMT
  7. Article-I.D.: clark.1992Nov19.225912.11004
  8. Distribution: usa
  9. Organization: Clark College, Vancouver, Wa.  USA
  10. Lines: 128
  11.  
  12.  
  13. Please email me at:
  14. frank@clark.edu
  15.   Can somebody explain why at LINK time I get an error for the static 
  16. initialization for class printerQue. I have compiled this program with 3
  17. different compilers: gcc(2.2.2), occ(Oregon C++ Compiler), Borland C++(3.0).
  18. I also can't get this program to compile correctly with Borland C++.
  19. However, occ will compile this program without any complications.
  20.   I would really like to get my program to compile with GCC. If
  21. you know what switches that need to be made at the prompt I would really
  22. appreciate it. Also, if there is anyone that can get this to work with
  23. Borland C++(3.0) or other I would like to know for kicks what I need 
  24. to do to make it work under Borland C++. Again I would like for this
  25. program to work with >>>GCC(2.2.2)<<<. If I need the new version of
  26. GCC then I'll shall get it.
  27.  
  28.   Thank you for your time.
  29. P.S.
  30. Please email me at: frank@clark.edu
  31.  
  32. -------------Error from output------------------
  33. Undefined                        first referenced
  34.  symbol                              in file
  35. _10printerQue.waiting                  q2.o
  36. _10printerQue.first                    q2.o
  37. _10printerQue.ready                    q2.o
  38. .....continued for static declarations.....
  39. ------------end of output----------------
  40. >>>>>>>>>>>>> START of Program <<<<<<<<<<<<<<<<<
  41. #include <iostream.h>
  42. #include <stdio.h>
  43. #include <strings.h>
  44. #define MAXJOBS 2
  45.  
  46. typedef enum Bool {true, false};
  47.  
  48. class baseQue
  49. {
  50. private:
  51.   Bool ok;
  52. protected:
  53.   baseQue *cur, *prv, *nxt, *top;
  54. public:
  55.   baseQue() 
  56.     {
  57.       cur = this; // point to the previous instance
  58.       cur->nxt = NULL; // point to the next NULL class.
  59.       top = this; // point to the current instance of the class
  60.     };
  61.   // Below are pure virtual functions that will change from the derived
  62.   // classes.
  63.  
  64.   virtual Bool addQue() = 0;
  65.   virtual Bool inQue() = 0;
  66.   virtual Bool outQue() = 0;
  67. };
  68.  
  69. class printerQue : public baseQue
  70. {
  71. private:
  72.   static Bool first; // used for beginning of linked list.
  73.   static int numjobs, // number of jobs total in que.
  74.              ready; // number of jobs that are ready to be processed.
  75.   Bool ok, // use for checking
  76.        waiting, // use for job waiting.
  77.        exec; // use for job executing.
  78.   
  79.   char s[30]; // somekind of string of control character.
  80.   
  81. public:
  82.   printerQue() 
  83.     {
  84.       first = true;
  85.       ok = true;
  86.       waiting = true;
  87.       exec = true;
  88.       numjobs = 0;
  89.       ready = 0;
  90.     }
  91.  
  92.   printerQue (char *trns)
  93.     { 
  94.       strncpy (s,trns,30);
  95.       cout << "in int :" << s;
  96.       outQue();
  97.     }
  98.       
  99.   Bool addQue ();
  100.   Bool inQue ();
  101.   Bool outQue();
  102. };
  103.  
  104. Bool printerQue :: addQue()
  105. {
  106.   while (waiting && numjobs > MAXJOBS)
  107.     {
  108.       cout << "waiting for 10 tries\n";
  109.       ++numjobs; // count up the number of jobs in que.
  110.     };
  111.   return true;
  112. };
  113.  
  114. Bool printerQue :: inQue()
  115. {
  116.   if (first) top = this; // done only one time.
  117.   prv = this; // set the current to the previous efore load the next.
  118.   nxt = new printerQue; // create a new instance.
  119.   if (nxt==NULL) return false; // unable to allocate memory.
  120.   cur = this->nxt; // set the current to the next
  121.   this->prv = prv; // this should tell the current to point to the previous
  122.   return true;
  123. };
  124.  
  125. Bool printerQue :: outQue()
  126. {
  127.   if (cur != top) cur = top;
  128.   cout << "\ns : " << *s;
  129.   for (;this->cur == NULL; this->nxt)
  130.     cout << "printing til end of que\n" << *s;
  131.   return true;
  132. };
  133.  
  134. int main()
  135. {
  136.   printerQue start("test");
  137. }  
  138.  
  139. >>>>>>>>>>> END of Program <<<<<<<<<<<<<
  140.