如何进行"C ++的合成"?在C ++/CLI中

编程入门 行业动态 更新时间:2024-10-20 20:39:43
本文介绍了如何进行"C ++的合成"?在C ++/CLI中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好! 我在用c ++/cli进行集装箱运输时遇到麻烦.我有两节课.一个是目录类,其数据成员为"System :: string ^ path",另一类是"file",其数据成员为"System :: String ^ name". 现在的想法是:目录包含一个文件(组成),并且目录可能没有任何文件(动态).我能够创建一个继承关系,但是显然没有任何意义.因此,我需要一些有关如何在两个类之间创建上述关系的帮助. 我的第二个问题是:我正在做一个项目,该项目索引指定路径的所有内容,然后提供不同的搜索方法.这些方法之一是按词搜索".我将它限制为大约20个预定义的单词.现在,我必须在控制台中打开一个文件(例如doc文件),然后进行字符串比较.但是我不知道如何在控制台中打开文件以及如何进行比较(我的意思是,如何将doc文件视为使用控制台创建的文件,以及如何将这些单词在System :: String中转换). 希望我能从你们这里得到一些帮助:).一个要求:请不要将第三方软件视为无法使用的解决方案(BOOST库和Dirent.h ...)

Hello everyone! I am facing trouble in doing containership in c++/cli. I have got two classes. One is a directory class with a data member "System::string^ path" and the other class is "file" with the data member "System::String ^ name". Now the idea is: directory contains a file(composition) and also, a directory may not have any file (dynamism). I am able to do create an inheritance relation, but obviously it doesn''t make any sense. So I need a little help on how to create the above described relation between the two classes. My second problem is: I am doing a project that indexes all the contents of a specified path and then offers different searching methods. One of these methods is, "search by word". I will be limiting it to some 20 predefined words. Now I have to open a file(say a doc file) in the console and then do the string comparision. But I don''t have any idea how to open the file in the console and also, how to do the comparison (I mean how a doc file will be treated as a file which is created by using console and how the words will be converted in System::String). Hope I will get some help from you people:). One request: Kindly don''t consider third party softwares as the solutions as I can''t use them(BOOST libraries and Dirent.h...)

推荐答案

1.我可以看到两个类之间没有任何关系,尽管Directory 对象可能包含File对象. 2.通过文件或流方法之一打开文件.如果通过doc文件表示MSWord文档,则需要引用互操作程序集 [ ^ ]. 另外,在第二个问题中,我没有看到您对控制台"的引用. 1. There is not any relationship between your two classes that I can see, although a Directory object may contain File objects. 2. You open a file by one of the file or stream methods. If by a doc file you mean a MSWord document then you will need to refer to the Interop assemblies[^] on MSDN. Also I don''t see the relevance of your references to "the console" in your second question.

除了Richard的回答:没有"open"之类的东西控制台中的文件".您只需打开一个文件,然后根据需要使用System::IO::StreamReader即可读取该文件. 如果您需要在Microsoft Word文档级别进行内容比较,则这是一个单独的问题.从这里开始: msdn.microsoft/en-us/library/z63ctsh2.aspx [ ^ ]或在此处: msdn.microsoft/en-us/library/bb726434 (v = office.12).aspx [ ^ ].
—SA
In addition to Richard''s Answer: there is no such thing as "open file in console". You just open a file, use System::IO::StreamReader as you need just to read it. If you need content comparison at the level of Microsoft Word document, this is a separate issue. Start from here: msdn.microsoft/en-us/library/z63ctsh2.aspx[^] or here: msdn.microsoft/en-us/library/bb726434(v=office.12).aspx[^].
—SA

更多推荐

如何进行"C ++的合成"?在C ++/CLI中

本文发布于:2023-11-07 06:12:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565750.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:quot   CLI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!