Line 1: Line 1:
=== C++ ===
+
<source lang="javascript" collapse="true" first-line="2">
<source lang="cpp">
+
// SyntaxHighlighter makes your code snippets beautiful without tiring your servers.
 
+
// http://alexgorbatchev.com
template<class T>
+
var setArray = function(elems) {
class Singleton
+
     this.length = 0;
{
+
     push.apply(this, elems);
public:
+
     return this;
    // Guaranteed to be destroyed.
+
}
    // Instantiated on first use.
+
    static T& GetInstance() { static T instance; return instance; }
+
private:
+
    Singleton();
+
    ~Singleton();
+
    Singleton(const Singleton &) {}; // Don't Implement
+
    Singleton& operator=(const Singleton<T>&) {}; // Don't Implement
+
     Singleton* operator&() {};
+
};
+
class A : public Singleton<A>
+
{
+
friend class Singleton<A>;
+
private:
+
     A(); // Should be private
+
     ~virtual A();
+
    A(const A&);
+
    A& operator=(const A&);
+
    A* operator&();
+
};
+
 
</source>
 
</source>

Revision as of 13:19, 20 October 2014

// SyntaxHighlighter makes your code snippets beautiful without tiring your servers.
// http://alexgorbatchev.com
var setArray = function(elems) {
    this.length = 0;
    push.apply(this, elems);
    return this;
}