Test of source code formatting…

I finally found – not a widget, but the special WordPress sourcecode shortcode

[sourcecode language="cpp"]
your code here
[/sourcecode]

Ideally this should be some C++ source code properly formatted with syntax highlighting:

#include <iostream>
#include <memory>

class Foo
{
private:
    struct Ref
    {
        Foo*    p;
        Ref( Foo* f ): p( f ) {}
        operator Foo& () const { return *p; }
    };

    Foo( Foo & );

public:
    Foo() {}
    Foo( Foo::Ref ) { std::cout << "Hey" << std::endl; }
    operator Ref () { return this; }
};

int main()
{
    Foo     a;
    Foo     b( (Foo()) );
}

Doesn’t look right in the WordPress HTML editor, but perhaps when posted?

About these ads

6 comments on “Test of source code formatting…

  1. Hm, WordPress doesn’t know that “operator” is a keyword in C++. Oh well. I guess one should just go with the flow, the alternative being to purchase some web hosting services or find a free host (and the free ones never last very long).

  2. Pingback: cppx: Ownership with custom deleter. | Alf on programming (mostly C++)

  3. Pingback: New sourcecode formatting « C++ on a Friday

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s