救命!!类的实例化出错
我在wsn.h文件中定义了类,在wsn.cpp文件中定义类的成员函数,然后再2.cpp文件中对类进行实例化,但是却报错了,错误如下:
D:\MyWork\wsn\2\2.cpp(219) : error C2143: syntax error : missing ';' before '.'
D:\MyWork\wsn\2\2.cpp(219) : error C2501: 'p' : missing storage-class or type specifiers
D:\MyWork\wsn\2\2.cpp(219) : error C2371: 'p' : redefinition; different basic types
D:\MyWork\wsn\2\2.cpp(218) : see declaration of 'p'
D:\MyWork\wsn\2\2.cpp(219) : error C2143: syntax error : missing ';' before '.'
Error executing cl.exe.
2.exe - 4 error(s), 0 warning(s)
wsn.h代码:
#ifndef wsn_h //预处理,封闭类的定义声明,防止多次包含相同的头文件
#define wsn_h
class NodeDevelper{ //节点布撒器
public:
NodeDevelper(); //构造函数
void poisson(); //产生泊松分布
conCheck(); //检查连通性
// ~conCheck(); //析构函数
void coverCheck(); //检查覆盖性
};
//NodeDevelper *p;
#endif
wsn.cpp代码:
/*定义成员函数*/
#include <iostream.h>
#include"wsn.h"
NodeDevelper::NodeDevelper(){
cout<<"dddd";
}
NodeDevelper::conCheck(){
cout<<"dddd";
}
2.cpp中的代码:
#include "stdafx.h"
#include "resource.h"
#include "iostream.h"
#include "wsn.h"
中间略
这里 如果写成这样就会出错
NodeDevelper p;
p.conCheck();
如果写成这样:
NodeDevelper conCheck();
就不会出错
请各位大哥帮我看看 为什么啊小妹在此谢过了