|
#1
|
|||
|
|||
[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] |
#2
|
|||
|
|||
[color=#000000ost_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?[/colorost_uid0]
__________________
Godfather of the wifflebat mafia. Bears are crazy, they\'ll bite your head off if you\'re wearing steak on it. |
#3
|
|||
|
|||
[color=#000000ost_uid0]Add a " at the end of the line.
Unterminated string constant means you didn't close a string somewhere.[/colorost_uid0] |
#4
|
||||
|
||||
[color=#000000ost_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:stream&" and see if it skips over any of them. Why strain your eyes looking for missing :'s?[/colorost_uid0]
__________________
My 5MV webpages My novel fivers list Yup “There must have been a point in early human history when it was actually advantageous to, when confronted with a difficult task, drop it altogether and go do something more fun, because I do that way too often for it to be anything but instinct.” -- Isto Combs |
#5
|
|||
|
|||
[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]
|
#6
|
||||
|
||||
[color=#000000ost_uid0]ooo C++. I should know this since I took 2 years of it. I think the previous people already solved it.[/colorost_uid0]
|
#7
|
|||
|
|||
[color=#000000ost_uid0]Okay, I found it. Subtle bug: the declaration inside ZStreamable declared zilla:perator<< to be a friend, but the actual operator was :perator<< (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.[/colorost_uid0] |
|
|