65,186
社区成员




//CharPtrTemplate.h
#ifndef CharPtrTemplate_H
#define CharPtrTemplate_H
#include <iostream>
template<const char* TP>
class CPT
{
const char* m_sz;
public:
CPT(const char* p):m_sz(p){}
void Print(void)
{
std::cout<<"the sz is("<<m_sz<<"),and the ptr value is("<<(int)m_sz<<")\n";
}
};
void InstanceA(void);
void InstanceB(void);
#endif
//a.cpp
#include "CharPtrTemplate.h"
void InstanceA()
{
CharPtrTemplate<"xxx"> a;
a.Print();
}
//b.cpp
#include "CharPtrTemplate.h"
void InstanceB()
{
CharPtrTemplate<"xxx"> b;
b.Print();
}
template<unsigned>
class T{};
T<(unsigned)"Hello"> t1;
T<(unsigned)"Hi"> t2;