home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / gnu / gcc / help / 1760 < prev    next >
Encoding:
Text File  |  1992-07-22  |  2.0 KB  |  81 lines

  1. Path: sparky!uunet!stanford.edu!ames!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!caen!kuhub.cc.ukans.edu!spssig.spss.com!uchinews!iitmax!gkt
  2. From: gkt@iitmax.iit.edu (George Thiruvathukal)
  3. Newsgroups: gnu.gcc.help
  4. Subject: Template Problems
  5. Message-ID: <1992Jul22.235122.17100@iitmax.iit.edu>
  6. Date: 22 Jul 92 23:51:22 GMT
  7. Organization: Illinois Institute of Technology / Academic Computing Center
  8. Lines: 71
  9.  
  10. Hello GNU Friends,
  11.  
  12. I am having a great deal of difficulty with templates in gcc 2.1. The 
  13. following three files are listed:
  14.   1. test2.C - a driver program to test drive my ordered list class
  15.   2. linked.h - an interface to "linked.C"
  16.   3. errors - error messages from gcc -c test2.C
  17.  
  18. A suspicious error message is being generated by the compiler to indicate
  19. that the object in the "." expression is not of an aggregate type, but by
  20. all evidence present it appears to be so. Thanks for any help. Should I
  21. be using gcc 2.2.2 ???
  22.  
  23. // This file is test2.C
  24.  
  25. #include "linked.h"
  26.  
  27. class Int {
  28. private:
  29.   int i;
  30. public:
  31.   Int(int i) : i(i) {};
  32. };
  33.  
  34. main()
  35. {
  36.   OrderedList<Int> ols();
  37.   Int a(25), b(30), c(35);
  38.   ols.insert(a);  // line 13
  39.   ols.insert(b);
  40.   ols.insert(c);
  41. }
  42.  
  43. // This file is linked.h
  44. #ifndef _LINKED_H_
  45. #define _LINKED_H_
  46.  
  47. template <class Value>
  48. class Linkable {
  49. friend class OrderedList;
  50. private:
  51.    Value &value;
  52.    Linkable *next;
  53. public:
  54.    Linkable(Value &v, Linkable *next) : value(v), next(next) { }
  55.  
  56. };
  57.  
  58. template <class Value>
  59. class OrderedList {
  60. private:
  61.    Linkable<Value> *front;
  62. public:
  63.    OrderedList(void);
  64.    int put(Value &v);
  65.    int remove(Value &v);
  66. };
  67.  
  68. #endif
  69.  
  70. // These are the errors generated when I compile test2.C (gcc -c)
  71.  
  72. test2.C: In function `int  main ()':
  73. test2.C:13: object in '.' expression is not of aggregate type
  74. test2.C:14: object in '.' expression is not of aggregate type
  75. test2.C:15: object in '.' expression is not of aggregate type
  76. -- 
  77. George K. Thiruvathukal
  78. IIT - School of Computer Science - gkt@iitmax.iit.edu
  79. Tellabs - Data Communications Division - att!tellab5!gkt
  80. Rapid Learning Curve
  81.