От: | Шахтер | ||
Дата: | 18.02.04 23:55 | ||
Оценка: |
/* main.cpp */
#include <iostream>
#include <typeinfo>
using namespace std;
/* struct Common<T> */
template <class T>
struct Common
{
int i;
static Common self;
};
template <class T>
Common<T> Common<T>::self={0};
template <class T>
Common<T> & common(const volatile T *)
{
return Common<T>::self;
}
/* struct Test */
struct Test
{
};
/* main() */
int main()
{
Test t;
Test *p=&t;
const Test *pc=p;
volatile Test *pv=p;
const volatile Test *pvc=p;
cout << typeid(&common(p)).name() << endl ;
cout << typeid(&common(pc)).name() << endl ;
cout << typeid(&common(pv)).name() << endl ;
cout << typeid(&common(pvc)).name() << endl ;
return 0;
}
struct Common<struct Test> *
struct Common<struct Test> *
struct Common<struct Test> *
struct Common<struct Test> *
Press any key to continue