一个C++重载符号错误问题
#include <iostream>
#include <vector>
#include <list>
#include <string.h>
using namespace std;
#ifndef DEPTREE_H
#define DEPTREE_H
#ifdef DLL_FILE
class _declspec(dllexport)DepTreeEntity //导出类Deptree
#else
class _declspec(dllimport)DepTreeEntity //导入类Deptree
#endif
ostream & operator << ( ostream & os , DepTreeEntity temp );
{
public:
//成员变量
int depId;
char depName[80];
//string depName;
int parentId;
char fullPath[80];
int nodeOrder;
int onlineChannelCount;
int offlineChannelCount;
//成员函数
void PrintId(void);
void PrintdepName(void);
void PrintparentId(void);
void PrintfullPath(void);
void PrintnodeOrder(void);
void PrintonlineChannelCount(void);
void PrintofflineChannelCount(void);
DepTreeEntity();
DepTreeEntity(int depId,const char* depName,int parentId,const char* fullPath,
int nodeOrder,int onlineChannelCount,int offlineChannelCount);
friend ostream & operator << ( ostream & os , DepTreeEntity temp );
};
#endif
这是其中一个类的声明,是要做DLL,我在控制台下已经运行成功,现在做DLL,当做头文件的时候出现这句话ostream & operator << ( ostream & os , DepTreeEntity temp );里面有好几个错误
error C2065: “os”: 未声明的标识符
C2872: “ostream”: 不明确的符号
求大神指教
[解决办法]
#ifndef DEPTREE_H
#define DEPTREE_H
//这些头文件丢到这里面来!
#include <iostream>
#include <vector>
#include <list>
#include <string.h>
using namespace std;
#include <iostream>
#include <vector>
#include <list>
#include <string.h>
using namespace std;
#ifndef DEPTREE_H
#define DEPTREE_H
#ifdef DLL_FILE
class _declspec(dllimport)DepTreeEntity //导出类Deptree
#else
class _declspec(dllimport)DepTreeEntity //导入类Deptree
#endif
{
friend ostream & operator << ( ostream & os , DepTreeEntity temp );
public:
//成员变量
int depId;
char depName[80];
//string depName;
int parentId;
char fullPath[80];
int nodeOrder;
int onlineChannelCount;
int offlineChannelCount;
//成员函数
void PrintId(void);
void PrintdepName(void);
void PrintparentId(void);
void PrintfullPath(void);
void PrintnodeOrder(void);
void PrintonlineChannelCount(void);
void PrintofflineChannelCount(void);
DepTreeEntity();
DepTreeEntity(int depId,const char* depName,int parentId,const char* fullPath,
int nodeOrder,int onlineChannelCount,int offlineChannelCount);
friend ostream & operator << ( ostream & os , DepTreeEntity temp );
};
#endif