Hey everyone!
So I'm trying to write a library which mimics the Java API using C++
(http://sf.net/projects/jalp4cpp). I've got some stuff done, but I
can't get the following code to work properly:
class String;
class Exception
{
public:
Exception();
Exception(String s);
String getMessage() const;
private:
String string;
};
class String
{
public:
String();
String(std::string s);
char charAt() const throw(Exception);
public:
std::string string;
};
Needless to say, the above dies with:
Exception.hpp:15: error: field 'string' has incomplete type
But if I try to flip the definition of String and Exception above, I
get the same error with Exception (because of the throw declaration).
I tried playing around with forward declarations, and #ifndef
#include-type stuff, and I can't get this to work.
I guess more importantly, I'm also trying to figure out why this
DOESN'T work. I mean, the code makes sense to me, but I'm not a
compiler. ;)
Thanks, everyone!