On 11/20/2012 01:02 PM, Matthew Gillen wrote:
> On 11/20/2012 12:41 PM, Greg London wrote:
>> In perl, it might look like this:
>>
>> sub upper_subroutine{
>>    my ($string)=@_;
>>    lower_subroutine("prefix".$string."postfix".timestamp());
>> }
>>
>> Could someone give me an example of how to do this in C++ so that
>> it looks as close to this perl code as possible?
>
> This will be useful to you for getting the timestamp aspect:
>  http://www.tutorialspoint.com/cplusplus/cpp_date_time.htm
>
> Other than that, use the '+' operator to concatenate C++ string
> objects, much like you use the '.' operator in perl.
>
> Note that you can run into issues if neither of the operands to '+'
> are actual std::string objects (e.g. "foo" + "bar" doesn't work in C++
> like it would in perl, since the literal string is not automatically
> promoted to std::string in some cases).
>
>> If this could happen without anyone having to die, that would
>> be even better.
>
> That's asking a lot ;-)
>
std::string("foo") + std::string("bar") yields the std::string "foobar :-)

-- 
Jerry Feldman <[email protected]>
Boston Linux and Unix
PGP key id:3BC1EB90 
PGP Key fingerprint: 49E2 C52A FC5A A31F 8D66  C0AF 7CEA 30FC 3BC1 EB90


Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Hardwarehacking mailing list
[email protected]
http://lists.blu.org/mailman/listinfo/hardwarehacking

Reply via email to