Index: [thread] [date] [subject] [author]
  From: Robert C. Duvall <rcd@cs.duke.edu>
  To  : 
  Date: 02 Feb 1999 20:40:24 -0500

Re: Weird Class Troubles

> In a class of mine i have a private variable
> 	map <string, Expression> myVars;
> Sadly, in a public function of the same class the command
> 	myVars.find(name)	// where name is a string
> creates this error:
> 	vars.h:18: request for member `find' in `VarNames::myVars', which is of non-aggregate type
> 		 `int'
> in addition to this error (which occurs whenever I call a function in the map class), some of my
> functions use the Expression class, with lines such as: 
> 	void Updatevar(const string & name, const Expression & value)
> which produces errors, persumably becuase
> 	vars.h:38: 'Expression' was not declared in this scope
> I #include both <stl.h> and "exptree.h"
> 
> Any ideas as to the reason for these errors.

This happens because you chose to implement your class inline (as in
the exptree_aux.h file).  However, you do not declare your instance
variables until the bottom of the class.  C++ does not know what you
have named them.  Two possible fixes: move your variable declarations
to the top ofthe class, or implement the member functions in a
separate file.

> (a second interesting facet of these errors is that
> they are displayed TWICE when i compile!)

Since the errors are in a header file (which is included from two
separate code files), you will get errors each time the compiler tries
to compile that code.


rcd


-- 
Robert C. Duvall
Lecturer, Duke University
rcd@cs.duke.edu


Index: [thread] [date] [subject] [author]