不确定如何用类实现MFC CArray [英] unsure how to implement MFC CArray with class

查看:54
本文介绍了不确定如何用类实现MFC CArray的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是模板编程的新手,我想使用MFC CArray创建一个

用户定义的类对象数组。通常我会使用链接的

列表处理 - 创建一个对象类,然后创建一个对象列表类,

但在这种情况下,数组处理会更有效。但是我需要使用可以动态缩小和增加Visual Basic

数组的数组。


我很困惑至于如何使用我的班级申报/实施CArray。


class mydatastruct

{

public:

mydatastruct();

~mydatastruct();

私人:

CString m_date;

double m_value;

};


如何声明mydatastructs的CArray实例?我是

认为这是我应该做的事情......


迈克

I am new to Template programming and I would like to create an array of
user-defined class objects using MFC CArray. Normally I would use linked
list processing - create an object class and then an object-list class,
but in this instance array processing would be more efficient. However I
need to use arrays that can dynamically shrink and grow ala Visual Basic
arrays.

I''m confused as to how to declare/implement the CArray using my Class.

class mydatastruct
{
public:
mydatastruct();
~mydatastruct();
private:
CString m_date;
double m_value;
};

How would I declare an instance of a CArray of mydatastructs? I''m
thinking this is something I should be able to do...

Mike

推荐答案

Mike Stenzler写道:
Mike Stenzler wrote:
我是模板编程的新手,我想用MFC CArray创建一个用户定义的类对象数组。通常我会使用
I am new to Template programming and I would like to create an array
of user-defined class objects using MFC CArray. Normally I would use



[SNIP]


常见问题解答:我应该在哪个新闻组发布我的问题?
< a rel =nofollowhref =http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9target =_ blank> http://www.parashift .com / c ++ - faq-lit ... t.html#faq-5.9


CArray,CString等是来自MFC的Microsoft专有类,并且是

在这里偏离主题。如果您决定使用std :: vector,这将是正确的

地址发布。


-

WW aka Attila


[SNIP]

FAQ: "Which newsgroup should I post my questions?"
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

CArray, CString etc. are Microsoft propriatery classes from MFC and are
off-topic here. If you decide to use std::vector, this will be the right
place to post to.

--
WW aka Attila


" Mike Stenzler" < MS ******* @ ssaris.com>在消息中写道

news:3F *************** @ ssaris.com ...
"Mike Stenzler" <ms*******@ssaris.com> wrote in message
news:3F***************@ssaris.com...
我是模板编程的新手我想使用MFC CArray创建一个用户定义的类对象数组。通常我会使用链接的列表处理 - 创建一个对象类,然后创建一个对象列表类,
但在这种情况下,数组处理会更有效。但是我需要使用能够动态缩小和增长Visual Basic数组的数组。


标准容器std :: vector可以做到这一点。

我推荐它超过特定于实现的

就像一个MFC类型。

我很困惑如何使用我的类声明/实现CArray。


class mydatastruct
{
公共:
mydatastruct();
~mydatastruct();
私人:
CString m_date;
double m_value;
};

如何声明mydatastructs的CArray实例?


阅读CArray文档。标准的C ++语言

(这里唯一的主题)无话可说。

我想知道这是我应该能做的事情做...
I am new to Template programming and I would like to create an array of
user-defined class objects using MFC CArray. Normally I would use linked
list processing - create an object class and then an object-list class,
but in this instance array processing would be more efficient. However I
need to use arrays that can dynamically shrink and grow ala Visual Basic
arrays.
The standard container std::vector can do this.
I recommend it over an implementation-specific
one like an MFC type.
I''m confused as to how to declare/implement the CArray using my Class.
class mydatastruct
{
public:
mydatastruct();
~mydatastruct();
private:
CString m_date;
double m_value;
};

How would I declare an instance of a CArray of mydatastructs?
Read the CArray documenation. The standard C++ language
(the only topic here) has nothing to say about it.
I''m
thinking this is something I should be able to do...




是的,我很确定。你还没看过你的文件吗?

应该用你的Windows编译器提供,

也在 www.msdn.microsoft.com


我还是推荐一个std :: vector,不过它可以做任何MFC CArray可以做的事情,并且可以在任何地方工作

这是一个标准的C ++实现。


- Mike



Yes, I''m sure it is. Haven''t you read your documentation?
It should be provided with your Windows compiler, and
also at www.msdn.microsoft.com

I still recommend a std::vector, though, it can do
anything an MFC CArray can do, and will work anywhere
there''s a standard C++ implementation.

-Mike




Mike Wahler写道:

Mike Wahler wrote:
标准容器std :: vector可以做到这一点。
我建议使用特定于实现的
类似MFC类型。


好​​的,我会咬...


如果我使用std :: vector而不是CArray,我该怎么办?实现一个简单的

类作为这些类对象的动态大小数组?
The standard container std::vector can do this.
I recommend it over an implementation-specific
one like an MFC type.
OK, I''ll bite ...

If I were to use std::vector instead of CArray, how would I implement a simple
class as a dynamically sizeable array of those class objects?
class mydatastruct
{
public:
mydatastruct();
~mydatastruct();
私人:
CString m_date;
double m_value;
};

怎么会我声明了一个mydatastructs的CArray实例?
阅读CArray文档。标准的C ++语言
(这里唯一的主题)无话可说。
class mydatastruct
{
public:
mydatastruct();
~mydatastruct();
private:
CString m_date;
double m_value;
};

How would I declare an instance of a CArray of mydatastructs?
Read the CArray documenation. The standard C++ language
(the only topic here) has nothing to say about it.
我是
认为这是我应该能做的事情做...
I''m
thinking this is something I should be able to do...



是的,我很确定。你还没看过你的文档吗?



Yes, I''m sure it is. Haven''t you read your documentation?



它应该随你的Windows编译器一起提供,
也在 www.msdn.microsoft.com

//下面的小咆哮


我理解为错误的新闻组发布CArray特定的帮助。

Mea Culpa,道歉。至于阅读文档 - 经过近20年后,作为一名专业程序员用6种语言编写,我不确定

有多少不同的操作系统环境,我''我们了解到并非所有文件都是平等的。有时RTFM不是对某些

洞察如何使用/做事的请求的恰当回应。有两个小孩和工作截止日期

的压力要求,我通常没有通过doco和

教我自己的奢侈品。当我正在尝试实施一项对我来说不熟悉的技术时。

当我依赖于询问拥有我需要的知识的其他人时 - 我认为

是Usenet的重要组成部分 - 人们分享

knowlege。

我还是推荐一个std :: vector,但它可以做到< MFC CArray可以做的任何事情,并且可以在任何地方工作
这是一个标准的C ++实现。


就像我说的,我会咬人的。你是如何使用的?

-Mike


It should be provided with your Windows compiler, and also at www.msdn.microsoft.com
// small rant below

I understand about posting to the wrong newsgroup for CArray-specific help.
Mea Culpa, my apologies. As for reading the documentation - after almost 20
years as a professional programmer writing in 6 languages under I''m not sure
how many different OS environments, I''ve learned that not all documentation is
equal. Sometimes RTFM isn''t the appropriate response to a request for some
insight into how to use/do things. Having 2 small children and job deadline
pressures to meet, I usually don''t have the luxury of poring through doco and
"teaching myself" when I''m trying to implement a technique that''s new to me.
That''s when I rely on asking others who have the knowledge I need - I thought
that was a big component of what Usenet was all about - people sharing
knowlege.

I still recommend a std::vector, though, it can do
anything an MFC CArray can do, and will work anywhere
there''s a standard C++ implementation.
Like I said, I''ll bite. How do you use it?
-Mike




谢谢


Mike Stenzler



Thanks

Mike Stenzler



这篇关于不确定如何用类实现MFC CArray的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆