64,654
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
class NULL_v
{
public:
template <typename T>
operator T *() const
{
return 0;
}
};
class String
{
public:
String(const char* s)
{
cout << "String(const char* s)" << endl;
}
~String()
{
cout << "~String()" << endl;
}
void test()
{
cout << "test()" << endl;
}
};
int main()
{
cout << "ctor" << endl;
String sss(NULL_v());
NULL_v null;
String ss(null);
ss.test();
cout << "dtor" << endl;
double* pd = NULL_v();
cout << pd << endl;
return 0;
}
String(const char* s)
{
cout << "String(const char* s) " <<(void*)s<< endl;
}
int a(int(a));
int b(int());
int c(int a);
int (x)(int(a));
int (y)(int());
int (z)(int a);
#include <iostream>
#include <typeinfo>
using namespace std;
class NULL_v
{
public:
template <typename T>
operator T *() const
{
return 0;
}
};
class String
{
public:
String(const char* s)
{
cout << "String(const char* s)" << endl;
}
~String()
{
cout << "~String()" << endl;
}
void test()
{
cout << "test()" << endl;
}
};
//这样做.
NULL_v make_null()
{
return NULL_v();
}
int main()
{
cout << "ctor" << endl;
String sss(make_null());
NULL_v null;
String ss(null);
ss.test();
sss.test();
cout << "dtor" << endl;
double* pd = NULL_v();
cout << pd << endl;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
class NULL_v
{
public:
template <typename T>
operator T *() const
{
return reinterpret_cast<T*>(888888);
}
};
class String
{
public:
String(const char* s)
{
printf("%x\n", s);
}
~String()
{
cout << "~String()" << endl;
}
void test()
{
cout << "test()" << endl;
}
};
int main()
{
cout << "ctor" << endl;
String sss(NULL_v());
NULL_v null;
String ss(null);
ss.test();
cout << "dtor" << endl;
double* pd = NULL_v();
cout << pd << endl;
return 0;
}