- 论坛徽章:
- 0
|
父类有个友元函数,在另外的某个模板类里面调用它作比较,
那么在写继承子类的时候,该如何处理这个友元函数呢?
直接直接编译的结果是通报link error
// .H
class Word;
typedef Word* WordPtr;
class Identifier;
typedef Identifier* IdentifierPtr;
class Word
{
friend int TreeDataCmp(const WordPtr&, const WordPtr& ;
// 难道这样写??
// friend int TreeDataCmp(const Identifier&, const Identifier& ;
public:
...
protected:
char* word;
};
class Identifier : public Word
{
public:
...
private:
int count;
};
/// .CPP
int TreeDataCmp(const WordPtr& w1, const WordPtr& w2)
{
return (strcmp(w1->;word,w2->;word));
}
谢谢^_^ |
|