简体   繁体   English

从C#背景学习C ++

[英]Learning c++ from a C# background

I want to learn c++ as I will be working on image recognition, etc. 我想学习c ++,因为我将从事图像识别等工作。

I have a few years solid experience in C# and I have made stuff with C# so I'm not lacking experience. 我有几年在C#方面的扎实经验,并且使用C#做过东西,所以我并不缺乏经验。 What is a good book which will help me make the transition (I will still be doing C# as it is my main skill)? 有什么好书可以帮助我过渡(我将继续从事C#,因为这是我的主要技能)?

Also, would you agree that to be good at C++, a lot of experience and being proficient in C# will help? 另外,您是否同意擅长C ++的丰富经验和精通C#会有所帮助? As C++ is harder... 由于C ++更难...

Thanks 谢谢

Also, would you agree that to be good at C++, a lot of experience and being proficient in C# will help? 另外,您是否同意擅长C ++的丰富经验和精通C#会有所帮助? As C++ is harder... 由于C ++更难...

Yes I agree with that. 是的,我同意这一点。 A lot of experience in development in any language helps in my opinion. 我认为,任何语言的开发经验都可以为您提供帮助。 With experience comes appreciation of best practices. 有了经验,就会对最佳实践产生赞赏。 Those practices may be different, but you will not dismiss them outright because you know (from your experience) that they are usually good for you. 这些做法可能有所不同,但是您不会直接将其解雇,因为您(从您的经验)知道它们通常对您有好处。
Good book... Get "C++ primer" with "Effective (and more effective) C++" and you will be all set. 好书...用“有效(且更有效)的C ++”获取“ C ++入门”,您将大功告成。 Then if you need STL get yourself Josuttis and "Effective STL". 然后,如果您需要STL,请使用Josuttis和“有效STL”。 Good luck 祝好运

Since you already know c# you already know more syntax than there is in c++. 由于您已经了解c#,因此您已经比c ++了解更多的语法。 There are very few c++ syntax elements that you'll need that are not also available in C#. 您需要的C ++语法元素很少,C#中也没有。

Here are the main areas where I think you see some challenges: 我认为您会在其中遇到一些主要挑战:

a) Many, many constructs in c# are simply not available in c++. a)c#中的许多构造根本无法在c ++中使用。 I'm talking about language features not data types. 我说的是语言功能而不是数据类型。 ie Generic Collections, etc... while similar results can be obtained with c++ language features it is soooo much more work in c++ 即通用集合等...虽然可以使用c ++语言功能获得类似的结果,但在c ++中的工作量却更多

b) It's really the libraries/framework you choose that are going to be substantially different. b)实际上,您选择的库/框架将有很大的不同。

c) Why not mix the two. c)为什么不将两者混在一起。 They both play well together. 他们俩在一起玩得很好。 Do your image processing work in a c++ library but keep the work there to a minimum and wrap the whole thing in c# for consumption in a UI. 在c ++库中执行图像处理工作,但将其中的工作保持在最低限度,然后将整个内容包装在c#中以在UI中使用。 Of course the interoperability will be another challenge but it is well documented on the web. 当然,互操作性将是另一个挑战,但在Web上已有很好的文档证明。

As far as good book goes... there is still none better than Steve McConnell's "Code Complete" 就好书而言……没有什么比史蒂夫·麦康奈尔的“代码完成”更好

http://cc2e.com/ http://cc2e.com/

Good Luck. 祝好运。

I learned C++ in college and found the Dietel book extremely thorough. 我在大学里学习了C ++,发现Dietel的书极其详尽。

Being proficient in C# helps but C++ is closer to C. 精通C#会有所帮助,但C ++更接近C。

I don't have any links on the subject, but I can offer some general advice. 我对此主题没有任何链接,但是我可以提供一些一般性建议。

  1. Remember that you no longer have memory management. 请记住,您不再具有内存管理。 You have to delete your pointers after you're done with them. 完成使用指针后,您必须删除它们。
  2. In C++, there is no physical difference between a struct and a class. 在C ++中,结构和类之间没有物理差异。 Both live on the heap or on the stack based on how you use them. 两者都根据您使用它们的方式而存在于堆或堆栈中。 In C#, a struct is a ValueType and lives on the stack, while a class is a ReferenceType and lives in the heap. 在C#中,结构是ValueType并存在于堆栈中,而类是ReferenceType并存在于堆中。 In C++, a struct has public member visibility by default, while a class has private member visibility by default; 在C ++中,结构默认情况下具有公共成员可见性,而类默认情况下具有私有成员可见性。 that's it. 而已。 In C++ a type (class or struct) lives on the stack by default, and only lives on the heap if you declare it as a pointer (and new it up). 在C ++中,默认情况下,类型(类或结构)驻留在堆栈上,并且仅当您将其声明为指针(并重新创建)时才驻留在堆上。
  3. Learn the Standard Template Library (STL). 了解标准模板库(STL)。 It's easily the best thing C++ has going for it. 这很容易是C ++所能做到的。
  4. Learn to hate the Microsoft Foundation CLass library (MFC), but learn to use it. 学习讨厌Microsoft Foundation CLass库(MFC),但学习使用它。 If you're doing windows development in C++, you pretty much have to do it. 如果您使用C ++进行Windows开发,则几乎必须这样做。

Also, would you agree that to be good at C++, a lot of experience and being proficient in C# will help? 另外,您是否同意擅长C ++的丰富经验和精通C#会有所帮助? As C++ is harder. 由于C ++更难。

Yeah I agree with you on the fact that C++ is harder. 是的,我同意C ++更难的事实。 In fact it is considered to be one of the most complicated programming languages. 实际上,它被认为是最复杂的编程语言之一。 Its syntax(at some places) is a bit ugly as compared to C# and Java but yeah it is one of the most widely used language in the industry, so best of luck with it. 与C#和Java相比,它的语法(在某些地方)有点丑陋,但是是的,它是业内使用最广泛的语言之一,所以祝您好运。

As far as good books are concerned I'll go with 至于好书,我会去

1) C++ Primer by Stan Lippman (strongly recommended) 1)Stan Lippman的C ++入门(强烈推荐)
2) Thinking in C++ by Bruce Eckel 2)Bruce Eckel用C ++进行思考

and style books like Effective and More Effective C++ by Scott Mayers. 和风格书籍,例如Scott Mayers撰写的有效和更有效的C ++。

Apart from that the 'Bible' for C++ is "The C++ Programming Language by Stroustrup". 除此之外,C ++的“圣经”是“ Stroustrup的C ++编程语言”。

Enjoy! 请享用!

I've actually done the conversion the other way around. 实际上,我已经完成了另一种转换。 I wouldn't say C++ is hard. 我不会说C ++很难。 Only as hard as you can make it. 只有尽力而为。 There are certain standard to follow with such things as memory allocation, pointers, type casting and etc. But it's nothing you cannot iron out as you get deeper into it. 遵循某些标准,例如内存分配,指针,类型转换等。但是,当您深入研究它时,就无所不能了。

Actually, (and some may see this as an overkill) if i were you i would try to get a decent assembler book and read the first few chapters on registers, memory addresses, stack, heap and etc. I think it'll paint a better picture for you when you start messing with memory management, which is probably the hardest thing to grasp in C/C++. 实际上,(有些人可能认为这太过分了)如果我是你,我会尝试拿一本不错的汇编书,并阅读有关寄存器,内存地址,堆栈,堆等的前几章。我认为它会画出一个当您开始弄乱内存管理时,这可能为您提供更好的画面,这在C / C ++中可能是最难掌握的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM