| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1648 人关注过本帖
标题:请问如何在Win32窗口应用程序中使用STL.NET?
只看楼主 加入收藏
liqing19861220
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-4-22
收藏
 问题点数:0 回复次数:0 
请问如何在Win32窗口应用程序中使用STL.NET?
我在实例化模板时老是提示

1>------ 已启动生成: 项目: myDE, 配置: Debug Win32 ------
1>正在编译...
1>myDE.cpp
1>正在链接...
1>myDE.obj : error LNK2020: 无法解析的标记(06000002) MyDeque.Deque <int>::push_back
1>G:\VC++2005我的工程\myDE\Debug\myDE.exe : fatal error LNK1120: 1 个无法解析的外部命令
1>生成日志保存在“file://g:\VC++2005我的工程\myDE\myDE\Debug\BuildLog.htm”
1>myDE - 2 个错误,0 个警告
========== 生成: 0 已成功, 1 已失败, 0 最新, 0 已跳过 ==========

我是在VS2005中创建Win32窗口应用程序的,我用了一个Deque模板类去包装了System::Collections::Generic下的array为Deque <Type>
结果对Deque <Type> myDeque任何成员函数的调用均出现上述错误。可我就是需要把array包装为Deque类....我看了MSDN的《 Primer》
,但是里面说的 <cli/deque>(文中称是在命名空间System::Collections::Generic)编译时也找不到。我实在是无路可走了!
    恳请各路高手指点迷津!!
   源代码如下:
//Form1.h-----------------------------------------------------------------------------------------------------
#pragma once

namespace myDE {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace cli;
using namespace System::Collections::Generic;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void){
InitializeComponent();
}

private:
Deque <int> tt;
protected:
~Form1()
{
if (components)
{
delete components;
}
}

private:
System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->SuspendLayout();
//  
// Form1
//  
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292, 266);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);

}
#pragma endregion
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
 //下面这一句注释掉就连警告都没有;没有注释掉就会出现一开始说的那个错误提示
 this->tt.push_back(1234);  }
};
}

//stdafx.h-----------------------------------------------------------------------------------------------------
// stdafx.h : 标准系统包含文件的包含文件,
// 或是经常使用但不常更改的
// 特定于项目的包含文件
#pragma once

// TODO: 在此处引用程序需要的其他头文件
#include "Deque.h"


//Deque.h----------------------------------------------------------------------------------------------------
#ifndef DEQUE_INCLUDE
#define DEQUE_INCLUDE
using namespace cli;
using namespace System;
using namespace System::Collections::Generic;
namespace MyDeque
{
template <class type>ref class Deque
{
public:
array <type>^  interDeque;
public:
Deque(){
interDeque = gcnew array <type>(2048);
base = 0;
top = 0;
}
int base;
int top;
int size();
type at(int pos);
void push_back(type);
type back();
type front();
void pop_back();
void clear();
};
}
using namespace MyDeque;
#endif

//Deque.cpp-----------------------------------------------------------------------------------------------------
#include "stdafx.h"
#include "Deque.h"

template <class type>int Deque <type>::size()
{
return this->interDeque->Length;
}

template <class type>type Deque <type>::at(int pos)
{
if( this->interDeque->Length  < pos )
return -1;
return this->interDeque->GetValue( pos );
}

template <class type>void Deque <type>::push_back(type elem)
{
this->interDeque->SetValue( elem, this->interDeque->Length );
}

template <class type>type Deque <type>::back()
{
return this->interDeque->GetValue(this->interDeque->Length - 1);
}

template <class type>type Deque <type>::front()
{
return this->interDeque->GetValue(this->interDeque->GetLowerBound());
}

template <class type>void Deque <type>::pop_back()
{
this->interDeque->Clear(this->interDeque, this->interDeque->Length - 1, 1);
}

template <class type>void Deque <type>::clear()
{
this->interDeque->Clear(this->interDeque,
this->interDeque->GetLowerBound(),
this->interDeque->GetUpperBound());
}
搜索更多相关主题的帖子: STL 应用程序 NET 窗口 
2008-04-22 15:10
快速回复:请问如何在Win32窗口应用程序中使用STL.NET?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014101 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved