xaut3 发表于 2010-5-14 07:03:51

C++学习中遇到的两个问题

问题一:类的静态指针类型的属性初使化
//test.h
class Test
{
...
public:
  static WORD* m_test;
...
}

//test.cpp
#include "test.h"
WORD* Test::m_test = 0;
...

问题二:类中的模板方法
类中的模板方法不能在cpp中实现,可以在h文件中定义时即实现:
//test.h
class Test
{
...
public:
  template<class T>
  BOOL TestMethod(T& result)
  {
    result = ...;
    return TRUE;
  }
...
}
页: [1]
查看完整版本: C++学习中遇到的两个问题

招聘斑竹