C++ function for a Perl guy

C++ and Perl programming tomes, photo by Thomas Guest on Flickr

Feeling a bit homesick for Perl with all this C++ I’ve been writing of late, so I did this. It even forces me to put a newline just like my beloved Perl print function.

#include <iostream>

void print(const std::string message) {
   cout << message;

Now that I think about it, we could even bring a touch of home to my Ruby side:

#include <iostream>

void puts(const std::string message) {
   cout << message << endl;

I giggled incessantly when writing these, due perhaps to sleep-deprived, broken-ankle, exam-anxiety induced state.

Alternatively, I could have just done this:

#include <string>
#include <stdio.h>

void print(const std::string message) {

But we all know how much C++ folks love when we mix in C stuff that has a C++ equivalent. I think I’ll stop now. #fallsasleep

Photo by Thomas Guest on Flickr.


This is one of about 5000 posts on Rubénerd. View the home page for the latest, or related posts also tagged with:

If you liked this post, feel free to buy me a coffee, leave me a comment on Twitter, or email me at weblog2017@rubenschade.com. Thanks :).