home *** CD-ROM | disk | FTP | other *** search
- 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
- From: gkt@iitmax.iit.edu (George Thiruvathukal)
- Newsgroups: gnu.gcc.help
- Subject: Template Problems
- Message-ID: <1992Jul22.235122.17100@iitmax.iit.edu>
- Date: 22 Jul 92 23:51:22 GMT
- Organization: Illinois Institute of Technology / Academic Computing Center
- Lines: 71
-
- Hello GNU Friends,
-
- I am having a great deal of difficulty with templates in gcc 2.1. The
- following three files are listed:
- 1. test2.C - a driver program to test drive my ordered list class
- 2. linked.h - an interface to "linked.C"
- 3. errors - error messages from gcc -c test2.C
-
- A suspicious error message is being generated by the compiler to indicate
- that the object in the "." expression is not of an aggregate type, but by
- all evidence present it appears to be so. Thanks for any help. Should I
- be using gcc 2.2.2 ???
-
- // This file is test2.C
-
- #include "linked.h"
-
- class Int {
- private:
- int i;
- public:
- Int(int i) : i(i) {};
- };
-
- main()
- {
- OrderedList<Int> ols();
- Int a(25), b(30), c(35);
- ols.insert(a); // line 13
- ols.insert(b);
- ols.insert(c);
- }
-
- // This file is linked.h
- #ifndef _LINKED_H_
- #define _LINKED_H_
-
- template <class Value>
- class Linkable {
- friend class OrderedList;
- private:
- Value &value;
- Linkable *next;
- public:
- Linkable(Value &v, Linkable *next) : value(v), next(next) { }
-
- };
-
- template <class Value>
- class OrderedList {
- private:
- Linkable<Value> *front;
- public:
- OrderedList(void);
- int put(Value &v);
- int remove(Value &v);
- };
-
- #endif
-
- // These are the errors generated when I compile test2.C (gcc -c)
-
- test2.C: In function `int main ()':
- test2.C:13: object in '.' expression is not of aggregate type
- test2.C:14: object in '.' expression is not of aggregate type
- test2.C:15: object in '.' expression is not of aggregate type
- --
- George K. Thiruvathukal
- IIT - School of Computer Science - gkt@iitmax.iit.edu
- Tellabs - Data Communications Division - att!tellab5!gkt
- Rapid Learning Curve
-