1、程序源文件:
#include "iostream" #include "NUM.h" using namespace std; int main() { cout<<"Hello world"<<endl; NUM a; a.Add(1);a.Add(3);a.Add(5); a.Display(); return 0; }
NUM.cpp: #include "iostream" #include "NUM.h" using namespace std; bool NUM::Add(int a) { vecArr.push_back(a); return true; } void NUM::Display() { for(vector<int>::iterator it = vecArr.begin(); it != vecArr.end(); it ) { cout<<*it<<'t'; } return ; }
NUM.h #include "vector" using namespace std; class NUM { public: bool Add(int a); void Display(); private: vector<int> vecArr; };
2、相应的Makefile文件hello.mk:
3、NMake的配置: .NET 2003Common7Tools中找到vsvars32.bat,在当前的dos窗口中运行它,以后在该窗口就能正常使用 NMake、cl、link了 |
|