CLI / C ++。与“普通” c ++或可视c#有什么不同? [英] CLI/C++. How does it differ to 'normal' c++ or visual c#?

查看:136
本文介绍了CLI / C ++。与“普通” c ++或可视c#有什么不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在学校里用Dev C ++编写了一些不太雄心勃勃的小型程序,现在已经上学了。但是现在出来了,我需要制作一个窗口应用程序。我看到有人为此使用Visual Studio。

I was programming some not ambitious, small programs in my school in Dev C++ for ages now in school. But now it came out i need to make a window application. I saw some people using visual studio for that.

几天前,我得到了Visual Studio C ++ Express,经过一段时间的编码,几行之后,我意识到它与我使用的普通 C ++有很大不同远。甚至字符串的声明也让我头疼。我想问一下,如果视觉C#与我所知道的更相似,或者对我来说,还有其他方法可以使用拖放界面在C ++中创建我所知道的C ++窗口应用程序,文本框和内容(例如在Visual Studio中)?

Few days ago i got Visual Studio C++ express, and i after a while of coding, after few lines i realized it differs much from "normal" C++ i was using so far. Even declarations of strings are giving me headache. I wanted to ask, if maybe visual c# would be more similar to what i know, or maybe there is some other way for me, to code window application in C++ i know, using drag and drop interface, when it comes to creating buttons, textboxes and stuff (like in visual studio)?

最重要的是,Visual c#更像是普通 c ++吗?如果没有,你们是否有取代Visual的建议?
任何帮助表示赞赏。

So most importantly, is Visual c# more like "normal" c++, and if not, do you guys got any suggestions to replace Visual? any help appreciated.

推荐答案

C ++和C ++ / CLI实际上只是不同的语言,设计用于不同的目的。 C ++ / CLI设计时考虑了一个目标-CLR,因此公开了垃圾回收的指针,接口,委托等类似语言的一流组件。 C ++ / CLI的设计使得可以将大多数有效的C ++代码编译为以CLR为目标,而无需重写。不利之处在于,编译现有的C ++代码通常将使用本机指针,除非将其置于 unsafe 模式,否则无法在CLR上表达该指针。这意味着您不能在部分信任的环境(例如Sliverlight或Windows Phone)中运行此类编译后的代码。

C++ and C++/CLI, are really just different languages, designed for different purposes. C++/CLI is designed with one target in mind -- the CLR, and thus exposes garbage collected pointers, interfaces, delegates, and similar as first class components of the language. C++/CLI is designed such that most code which is valid C++ can be compiled to target the CLR without being rewritten, however. The downside here is that compiling existing C++ code will typically use native pointers, which cannot be expressed on the CLR unless it is put into unsafe mode. This means you can not run such compiled code in partial trust environments, such as Sliverlight or Windows Phone.

C ++是一种通用编程语言,旨在针对所有计算机系统,从最大的大型机到最小的微控制器。没有诸如垃圾收集指针或委托之类的功能可用,因为在某些类型的硬件上提供此类功能非常困难。

C++, on the other hand, is a general purpose programming language designed to target all computer systems, from the largest mainframe to the smallest microcontroller. There are not features like garbage collected pointers or delegates available because providing such features would be extremely difficult on some types of hardware.

实际上,尽管共享相似的语法,但它们是两个完全独立的语言。 C ++ / CLI通常以比C#更接近C ++的方式编写。

Really, despite sharing similar syntax, they are two completely separate languages. C++/CLI is usually written in a style closer to C# than to C++.

现在,要解决您的特定问题:

Now, to address your specific concerns:


甚至字符串的声明也让我头疼。

Even declarations of strings are giving me headache.

C ++ / CLI提供了 System :: String 类型作为其基类库的一部分。标准C ++还提供 std :: basic_string (专门用于<$时,将其类型定义为 std :: string c $ c> char )因此,您可能会看到某些类型的冲突,并且处理此冲突的唯一方法通常是明确指定您要的冲突。

C++/CLI provides a System::String type as part of it's base class library. Standard C++ also provides std::basic_string (which is typedef'd to std::string when specialized for char) Therefore, you might see some kinds of conflicts, and the only way to deal with this is usually to specify the one you want explicitly.


我想问一下,也许视觉c#与我所知道的更相似,或者对我来说,还有其他方法可以用我知道的C ++编写窗口应用程序,使用拖放界面来创建按钮,文本框和内容(例如在Visual Studio中)?

I wanted to ask, if maybe visual c# would be more similar to what i know, or maybe there is some other way for me, to code window application in C++ i know, using drag and drop interface, when it comes to creating buttons, textboxes and stuff (like in visual studio)?

编辑:在Visual Studio 2010中,以下内容可能不再成立。我没有机会进行验证。 (有关更多详细信息,请参见此答案的评论)。

EDIT : The following may no longer be true in Visual Studio 2010. I've not had a chance to verify. (See comments on this answer for more details)

Visual Studio中没有提供用于生成C ++应用程序的可视设计器工具。有WPF和Windows窗体的设计器,它们都是CLR技术。要使用这些设计器,您必须使用C ++ / CLI,而不是C ++。

There is no visual designer kind of tool available in Visual Studio to produce C++ applications. There are designers for WPF and Windows Forms, both of which are CLR technologies. To use these designers you must use C++/CLI, rather than C++.

这篇关于CLI / C ++。与“普通” c ++或可视c#有什么不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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