Confusing C ++ syntax.

Source: Internet
Author: User

# Include <iostream>
# Include <cstddef> // For size_t
Using namespace STD;

// Arr 13 run error in vs.net

/* Template <class key>
Struct myhash
{
Void operator ()()
{
Cout <"myhash <t>" <Endl;
}
};

_ Stl_template_null struct myhash <char>
{
Void operator ()()
{
Cout <"myhash <char>" <Endl;
}
};

_ Stl_template_null struct myhash <unsigned char>
{
Void operator ()()
{
Cout <"myhash <unsigned char>" <Endl;
}
};

Int main ()
{
Myhash <long> T1;
Myhash <char> T2;
Myhash <unsigned char> T3;

T1 ();
T2 ();
T3 ();

Return 0;
}
*/

// Arr 12

/* Class alloc
{
};

Template <class T, class alloc = alloc, size_t buffsize = 0>
Class mydeque
{
Public:
Mydeque ()
{
Cout <"mydeque" <Endl;
}
};

Template <class T, class sequence>
Class mystack;

Template <class T, class sequence>
Bool operator = (const mystack <t, sequence> & X, const mystack <t, sequence> & Y );

Template <class T, class sequence>
Bool operator <(const mystack <t, sequence> & X, const mystack <t, sequence> & Y );

Template <class T, class sequence = mydeque <t>
Class mystack
{
Public:
Friend bool operator ==< T> (const mystack <t> &, const mystack <t> &);
Friend bool operator <t> (const mystack <t> &, const mystack <t> &);

Mystack ()
{
Cout <"mystack" <Endl;
}

PRIVATE:
Sequence E;
};

Template <class T, class sequence>
Bool operator = (const mystack <t, sequence> & X, const mystack <t, sequence> & Y)
{
Cout <"operator =" <Endl;
Return true;
}

Template <class T, class sequence>
Bool operator <(const mystack <t, sequence> & X, const mystack <t, sequence> & Y)
{
Cout <"opeartor <" <Endl;

Return false;
}

Int main ()
{
Mystack <int> X;
Mystack <int> Y;

Cout <(x = y) <Endl;
Cout <(x <Y) <Endl;

Return 0;
}*/

// Arr 11
/* Class alloc
{
};

Inline size_t _ deque_buf_size (size_t N, size_t Sn)
{
Return n! = 0? N: (Sn <512? Size_t (512/SN): size_t (1 ));
}

Template <class T, class ref, class PTR, size_t buffsize>
Struct _ deque_iterator
{
Typedef _ deque_iterator <T, T &, T *, buffsize> iterator;
Typedef _ deque_iterator <t, const T &, const *, buffsize> cosnt_iterator;

Static size_t buffer_size ()
{
Return _ deque_buf_size (buffsize, sizeof (t ));
}
};

Template <class T, class alloc = alloc, size_t bufsize = 0>
Class mydeque
{
Public:
Typedef _ deque_iterator <T, T &, T *, bufsize> iterator;
};

Int main ()
{
Cout <mydeque <int >:: iterator: buffer_size () <Endl;
Cout <mydeque <int, alloc, 64 >:: iterator: buffer_size () <Endl;

Return 0;
}*/

// Arr 10
/* Class alloc
{
};

Template <class T, class alloc = alloc, size_t bufsize = 0>
Class mydeque
{
Public:
Mydeque ()
{
Cout <"deque" <Endl;
}
};

Template <class T, class mysequence = mydeque <t>
Class mystack
{
Public:
Mystack ()
{
Cout <"stack" <Endl;
}

PRIVATE:
Mysequence C;
};

Int main ()
{
Mystack <int> X;

Return 0;
}*/

// Arr 08
/* Class alloc
{
};

Template <class T, class alloc = alloc>
Class myvector
{
Public:
Typedef t value_type;
Typedef value_type * iterator;

Template <class I>
Void insert (iterator position, I first, I last)
{
Cout <"insert" <Endl;
}
};

Int main ()
{
Int Ia [5] = {0, 1, 2, 3, 4 };

Myvector <int> X;
Myvector <int >:: iterator ite = NULL;

X. insert (ITE, IA, Ia + 5 );

Return 0;
}
*/

// Arr06
/* Class alloc
{
};

Template <class T, class alloc = alloc>
Class myvector
{
Public:
Void swap (myvector <t, alloc> &)
{
Cout <"swap ()" <Endl;
}
};

Template <class T, class alloc>
Inline void swap (myvector <t, alloc> & X, myvector <t, alloc> & Y)
{
X. Swap (y );
}

Int main ()
{
Myvector <int> X, Y;
Swap (x, y );
}
*/

// Arr 05
/* Template <Class I, Class O>
Struct testclass
{
Testclass ()
{
Cout <"I, O" <Endl;
}
};

Template <class T>
Struct testclass <t *, T *>
{
Testclass ()
{
Cout <"T *, T *" <Endl;
}
};

Template <class T>
Struct testclass <const T *, T *>
{
Testclass ()
{
Cout <"const T *, T *" <Endl;
}
};

Int main ()
{
Testclass <int, char> obj01;
Testclass <int *, int *> obj02;
Testclass <const int *, int *> obj3;
}

*/
// Arr03

/* Template <typename T>
Class testclass
{
Public:
Static T _ data;
};

Int testclass <int >:: _ DATA = 1;
Char testclass <char >:: _ DATA = 97;

Int main ()
{
Cout <"testclass <int>: _ DATA =" <testclass <int>: _ DATA <Endl;
Cout <"testclass <char >:: _ DATA =" <testclass <char >:: _ DATA <Endl;
}*/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.