vs2008里,创建c++.net的项目,怎么引用自己的类库呢
用vs2008新建立了一个Solution2的解决方案,新建完这后,添加一个windows窗体应用程序(c++的)Test1如图:
这后在添加一个名字为LR500的类库(也是c++的),如图:
在默认生成的文件LR500.h中的加入如下代码:
// LR500.h#pragma once#ifndef LR500#define LR500using namespace System;namespace LR500 { public ref class Class1 { // TODO: 在此处添加此类的方法。 public: Class1(); Class1(int index); private: int _index; };}#endif
// 这是主 DLL 文件。#include "stdafx.h"#include "LR500.h"LR500::Class1::Class1(){ this->_index = 0;}LR500::Class1::Class1(int index){ this->_index = index;}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { LR500::Class1 cls1(2); }
[color=#FF0000]#ifndef LR500#define LR500...#endif[/color]