Visual Studio 2010 C ++;组织课程 [英] Visual Studio 2010 C++; organizing classes

查看:76
本文介绍了Visual Studio 2010 C ++;组织课程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在vis studio 6.00中,我可以制作地图以订购项目文件.我现在如何在2010年做到这一点?我的项目中有很多文件,我想将属于同一文件的文件放在一起,这样我就不必查看不需要的文件(类).

现在vis studio按字母顺序订购它们.这对我来说不切实际.

我的项目有很多课程.有些课程是相关的,我想实现的只是一种组织它们的方式.当我在项目的特定部分工作时,我只对程序中该部分所涉及的类感兴趣.此外:以某种方式对文件进行排序会很好.现在,每个.h/.cpp文件都位于同一项目目录中.

(如何为问题添加屏幕截图?)

In vis studio 6.00 I could make maps to order my project files. How can I do this now in 2010? My project has a lot of files and I want to put the files together who belong together so I don''t have to see files (classes) I don''t need.

Now vis studio orders them alphabetically. That is not practical for me.

My project has a lot of classes. Some classes are related and all I want to achieve is a way to organize them. When I''m working on a particular part of the project I''m only interested in the classes involved in that part of the program. Furthermore: It would be nice to have the files ordened in some way. Now every .h / .cpp file is in the same project directory.

(How can I add an screenshot to my question ? )

推荐答案

涉及C ++时,它与Visual Studio无关,也有很多事情要做语言和项目结构本身. (使用不同的语言,情况就大不相同:.NET语言没有include,并且文件结构对项目构建没有任何影响,因此您拥有最大的自由度;但是对于F#,声明的顺序是必不可少的,因此VS为您提供了一种订购文件的方法.

只是一个提示:如果您不喜欢字母顺序(这对我也没有什么价值),请尝试将文件组织到以语义命名的子目录中.创建它们的最佳方法是从VS,因为它将确保项目结构与文件系统结构匹配.现在请记住,C ++绑定基于#include和目标文件,而在源代码级别上没有任何类型的模块,因此您需要彻底规划目录结构,以确保保留对包含文件和包含顺序的依赖性,因此,始终会找到包含的文件,并以正确的顺序包含这些文件.为此,请计划一些由这些子目录及其依赖关系表示的功能块.

—SA
When it comes to C++, it has nothing a little to do with Visual Studio and a lot to do with the language and project structure itself. (With different languages, situation is very different: for .NET languages, there is no include, and the file structure has no effect on the project build whatsoever, so you have the most freedom; but with F#, the order of declaration is essential, so the VS gives you a way to order files).

Just one hint to make: if you don''t like alphabetical order (which has little value to me, too), try to organize files into semantically named sub-directories. The best way to create them is from the VS as it will make sure that the project structure will match file system structure. Remember now, that C++ binding is based on #include and object files without any kind of modules at the level of source code, so you need to plan directory structures thoroughly to make sure to preserve dependency on included files and the order of includes, so included files are always found and included in proper order. To do this, plan some functional blocks represented by those sub-directories and dependencies between them.

—SA


要在Studio中创建简单的逻辑分隔(与从目录中移动文件无关),您实际上可以像已设置的目录一样创建目录为您服务(通常在我头顶上方的两个或三个)是标题",资源"和源"或类似名称.您可以在文件浏览器(在Studio中)中右键单击主项目,然后添加所需数量的目录,然后将文件拖到目录中.由于分离仅发生在您的Studio项目中,因此不会弄乱您的包含对象.

抱歉,如果我没有发布详细信息,我正在通过手机发布.
To create simple logical separation within studio (not related to moving files from their directories) you can actually make directories just like the ones that are already set up for you (theres usually two or three, off the top of my head they''re "headers", "resources", and "source" or something similar). You can right click on the main project within the file browser (in studio) and add as many directories as you want then just drag files into your directories. Since the separation occurs only within your studio project it won''t mess up your includes.

Sorry if I don''t post great details, I''m posting from my phone.


Albert,

这正是我的意思...但是...

在类查看器中,可以创建一个新文件夹(使用左上角的新文件夹"图标).新文件夹出现在项目上方(我的解决方案中有更多项目).我无法将新文件夹移动到我想要的项目中...

当我将类从项目拖到新文件夹中时,旧的文件夹仍然存在.这些类的属性告诉我两个类(原始类和新文件夹中的一个)是相同的.我现在不介绍如何在不删除文件的情况下从项目中删除原始类.以某种方式,将类组织在硬盘上实际的Windows子文件夹中,并以某种方式在类查看器中进行构建,对我来说也很方便.

所以..
1)新文件夹在查看器中的错误位置....
2)如何从项目中删除(不删除!)类到新文件夹

我会请您尝试一次,然后告诉我您也有同样的经历.可能在Visual Studio中进行一些设置(我使用标准安装方式)将对我有所帮助,或者是一些精美的右键单击选项……对我来说似乎很奇怪,我是世界上唯一一个像这样工作的人...

再次:非常感谢您的努力
Albert,

This is exactly what I mean... but....

In the class viewer one can make a new folder (using the new folder icon on the top left). The new folder appears above the project (I have more projects in my solution). I cannot move the new folder to the project I want...

When I drag my classes from the project to the new folder the old one still exists. Properties of the classes tell me both classes (original and the one in the new folder) are the same. I don''t now how to remove the original class from the project whithout deleting the file. Somehow it would be convenient for me to have the classes organised in actual windows sub folders on the harddisk and to have that structure somehow in the class viewer also.

so..
1) The new folder is on the wrong place in the viewer....
2) How to remove (not to delete!) the classes from the project to the new folder

I would ask You to try it once and tell me You have the same experience. Probably some setting in visual studio (I use the standard installation) will help me or some fancy right mouse options are whatever... It seems strange to me I''m the only one in the world working like this...

Again: Thank You pretty much for your effort


这篇关于Visual Studio 2010 C ++;组织课程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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