The Five-Minute Forums

The Five-Minute Forums (http://www.fiveminute.net/forums/index.php)
-   Miscellaneous (http://www.fiveminute.net/forums/forumdisplay.php?f=10)
-   -   Heads up to Zeke - And any other code goons (http://www.fiveminute.net/forums/showthread.php?t=172)

Angstrom 04-02-2003 12:38 AM

[color=#000000:post_uid0]What's wrong with this code?

[b:post_uid0]ZStreamable.hpp[/b:post_uid0]
[code:1:post_uid0]namespace zilla {
class ZStreamable;
}

std::ostream& operator<<(std::ostream& out, const zilla::ZStreamable& obj); // line 13

namespace zilla {
class ZStreamable {
public:
ZStreamable ();
virtual ~ZStreamable ();

virtual void render (std::ostream &out) const = 0;

friend std::ostream& operator<<(std::ostream& out, const zilla::ZStreamable& obj); // line 23
};
}[/code:1:post_uid0]

[b:post_uid0]PageFooter.hpp[/b:post_uid0]
[code:1:post_uid0]namespace zilla {
class PageFooter : public ZStreamable {
public:
virtual void render (std::ostream &out) const;
};
}[/code:1:post_uid0]

[b:post_uid0]index.cgi.cpp[/b:post_uid0]
[code:1:post_uid0]// other code, main, etc etc
cout << PageFooter (); // line 72
// mode code[/code:1:post_uid0]

[b:post_uid0]make[/b:post_uid0]
[code:1:post_uid0]g++ -g -Wall -pedantic -ansi -lcgicc index.cgi.cpp HTTPHTMLCharsetHeader.o XHTMLDoctype.o PageFooter.o ZStreamable.o -o index.cgi
index.cgi.cpp: In function `int main(int, char**)':
index.cgi.cpp:72: ambiguous overload for `std::ostream& << zilla::PageFooter'
operator
ZStreamable.hpp:13: candidates are: std::ostream& operator<<(std::ostream&,
const zilla::ZStreamable&)
ZStreamable.hpp:23: std::ostream&
zilla::operator<<(std::ostream&, const zilla::ZStreamable&)
ZStreamable.hpp:23: std::ostream&
zilla::operator<<(std::ostream&, const zilla::ZStreamable&)[/code:1:post_uid0][/color:post_uid0]

Wonko The Sane 04-02-2003 01:21 AM

[color=#000000:post_uid0]Yeah, all day today I've been getting a runtime error that sounded something like this:

Line: 176
Error: Unterminated String Constant

Now if I had some clue on how to use C++, I'd know what that would mean...but my programming is limited to Visual Basic and Java.

I figure that the error will be fixed when everything flips back to forwards which is the inverse of the backwards way became when the calender flipped forwards from yesterday to today, and will be rectified when the calender flips forward to the...[okay, you get the picture].
:smile:

EDIT: Did I mention that I only know a very limited amount of Java?[/color:post_uid0]


Angstrom 04-02-2003 01:46 AM

[color=#000000:post_uid0]Add a " at the end of the line.

Unterminated string constant means you didn't close a string somewhere.[/color:post_uid0]

NAHTMMM 04-02-2003 02:54 AM

[color=#000000:post_uid0]Maybe you could copy it all into Word, then run a text search to see if everything you want spelled the same *is* spelled the same. That is, tell the program to search for "std::ostream&" and see if it skips over any of them. Why strain your eyes looking for missing :'s?[/color:post_uid0]

Angstrom 04-02-2003 04:04 AM

[color=#000000:post_uid0]Actually, I've already copy/pasted the function definition into the friend definition, and removed unnnecessary scopes. Didn't help any. I think my use of friend is just wrong, but it looks right.[/color:post_uid0]

NeoMatrix 04-02-2003 04:26 AM

[color=#000000:post_uid0]ooo C++. I should know this since I took 2 years of it. I think the previous people already solved it.[/color:post_uid0]

Angstrom 04-02-2003 10:06 PM

[color=#000000:post_uid0]Okay, I found it. Subtle bug: the declaration inside ZStreamable declared zilla::operator<< to be a friend, but the actual operator was ::operator<< (no namespace).

Besides which I've switched back to cgicc::MStreamable instead of my custom ZStreamable, because I was able to work out my issues from that.[/color:post_uid0]


All times are GMT. The time now is 10:10 AM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.