On Thursday 14 July 2005 02:45, Juan Alberto Cirez wrote:
> Hi all,
> I will be giving a presentation in a couple of days and I wanted to
> compare and contrast several programming languages (i.e C/C++; Java;
> Perl & PhP). As an example I have a short function (a method in Java)
> and I wanted its equivalent in C++ (not C)
>
> public String commentTag(String content) {
> return ((content.length() > 0) ? "<!--"+comment+"//--> : "<!--Default
> comment //-->");
> }
sure, with a test program so you can compile it and try it out:
#include <string>
#include <iostream>
using namespace std;
string commentTag(const string& content)
{
return (content.length() > 0) ? "<!--" + content + "//-->"
: "<!--Default comment //-->";
}
int main(int argc, char* argv[])
{
string foo;
cout << commentTag(foo) << endl;
foo.append("woot");
cout << commentTag(foo) << endl;
return 0;
}
btw.. there are bugs in your java implementation.
"<!--"+comment+"//-->
should be:
"<!--"+content+"//-->"
--
Aaron J. Seigo
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA EE75 D6B7 2EB1 A7F1 DB43
pgpnL2zJfIzQF.pgp
Description: PGP signature
_______________________________________________ clug-talk mailing list [email protected] http://clug.ca/mailman/listinfo/clug-talk_clug.ca Mailing List Guidelines (http://clug.ca/ml_guidelines.php) **Please remove these lines when replying

