visual-studio 在 Visual Studio 中从头开始学习 C++?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1089437/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:43:57  来源:igfitidea点击:

Learning C++ from scratch in Visual Studio?

c++visual-studiomanaged-c++

提问by flesh

I need to get up to speed with C++ quite quickly (I've never used it previously) - is learning through Visual Studio (i.e. Managed C++) going to be any use? Or will I end up learning the extensions and idiosyncracies of C++ in VS, rather then the language itself?

我需要很快掌握 C++(我以前从未使用过它)——通过 Visual Studio(即托管 C++)学习有什么用吗?或者我最终会在 VS 中学习 C++ 的扩展和特性,而不是语言本身?

If learning in VS is not recommended, what platform / IDE do you guys suggest?

如果不建议在 VS 中学习,你们建议使用什么平台/IDE?

Edit:Can anyone elaborate on what VS will hide or manage for me when coding unmanaged C++? I really need to be learning things like pointers, garbage collection and all the nuts and bolts of the low level language.. does VS abstract or hide any of this kind of stuff from you?

编辑:任何人都可以详细说明在编码非托管 C++ 时 VS 将为我隐藏或管理什么?我真的需要学习诸如指针、垃圾收集和低级语言的所有细节之类的东西.. VS 是否抽象或隐藏了任何此类东西?

Thanks for all the suggestions..

感谢所有的建议..

回答by jalf

Visual Studio (or the free version, Visual C++ Express) is a perfectly fine choice on Windows. On Linux, you'll probably end up using GCC. Both are fine compilers.

Visual Studio(或免费版本,Visual C++ Express)是 Windows 上的完美选择。在 Linux 上,您可能最终会使用 GCC。两者都是很好的编译器。

Visual C++ supports both "real" native C++ and C++/CLI, the managed .NET version, so if you want to learn C++, simply create a regular C++ project.

Visual C++ 支持“真正的”本机 C++ 和 C++/CLI(托管 .NET 版本),因此如果您想学习 C++,只需创建一个常规 C++ 项目即可。

If you're concerned with learning "proper" standard C++, note that the compiler by default enables a number of Microsoft extensions, which you may want to disable. (Project properties -> C/C++ -> Language -> Disable Language Extensions).

如果您关心学习“正确的”标准 C++,请注意编译器默认启用许多 Microsoft 扩展,您可能希望禁用这些扩展。(项目属性 -> C/C++ -> 语言 -> 禁用语言扩展)。

For the record, GCC has similar extensions (which can be disabled by calling the compiler with --ansi), so this isn't just Microsoft being big and evil and nonstandard. ;)

作为记录,GCC 有类似的扩展(可以通过使用 --ansi 调用编译器来禁用它),所以这不仅仅是微软的大、邪恶和非标准。;)

回答by Cristian Adam

Visual Studio has a very good debugger. It has support for STL types (version 2008 is better) which will help you while debugging.

Visual Studio 有一个非常好的调试器。它支持 STL 类型(2008 版更好),这将在调试时为您提供帮助。

Visual Studio insists with the Microsoft specifics from the very first console project you make (New->Project->Win32 Console Application)

Visual Studio 坚持使用您制作的第一个控制台项目(New->Project->Win32 Console Application)中的 Microsoft 细节

// test123.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
    return 0;
}

What is stdafx.h? What is _tmain? What is _TCHAR? (BTW no need to answer them here) These are question which should not appear in the head of a novice.

什么是 stdafx.h?什么是_tmain?什么是_TCHAR?(顺便说一句,这里不需要回答)这些问题不应该出现在新手的脑海中。

That's why I suggest to use the "Empty project" checkbox in the Win32 Console Application project and then "Add new item" from Project menu and choose a cpp file which will give you a blank page where you can implement the code you read from a good C++ book.

这就是为什么我建议在 Win32 控制台应用程序项目中使用“空项目”复选框,然后从“项目”菜单中“添加新项目”并选择一个 cpp 文件,该文件将为您提供一个空白页面,您可以在其中实现您从很好的 C++ 书。

回答by ChrisW

The Visual Studio IDE can be used with several languages: for example C#, managed C++, and also the real (unmanaged) C++, so:

Visual Studio IDE 可用于多种语言:例如 C#、托管 C++,以及真正的(非托管)C++,因此:

  1. You can use VS for the real C++, not just for the "managed" C++.
  2. If you just want to learn C++ then, you're right, you don't want to be learning "managed" C++.
  1. 您可以将 VS 用于真正的 C++,而不仅仅是用于“托管”C++。
  2. 如果您只是想学习 C++,那么您是对的,您不想学习“托管”C++。

回答by sreenath

Eclipse is an excellent IDE that works with many languages, including c++. The Eclipse CDT can be found here: http://www.eclipse.org/cdt/

Eclipse 是一款出色的 IDE,可用于多种语言,包括 C++。Eclipse CDT 可以在这里找到:http: //www.eclipse.org/cdt/

回答by Edison Gustavo Muenz

Visual studio is not necessarily managed c++. You can compile it with that option, but it's not necessary.

Visual Studio 不一定是托管 C++。您可以使用该选项编译它,但这不是必需的。

In my opinion learning using visual studio is a great option since you can right into the code and don't bother much about the configuration of your project.

在我看来,使用 Visual Studio 学习是一个很好的选择,因为您可以直接进入代码,而不必太在意项目的配置。

回答by Sam Saffron

It all depends, first step would be to read quite a few books, some basic ones, and some advanced ones like effective C++.

这一切都取决于,第一步是阅读不少书籍,一些基础书籍和一些高级书籍,如有效的 C++。

Managed C++ is a very different beast to pure C++, besides VS lets you program in pure C++ anyway. So, if your goal is to learn pure C++, I do not think you need to learn the managed extensions.

托管 C++ 是与纯 C++ 截然不同的野兽,此外 VS 无论如何都允许您使用纯 C++ 进行编程。因此,如果您的目标是学习纯 C++,我认为您不需要学习托管扩展。

Can you elaborate on why exactly you need to learn C++? what kind of project you will be working on?

你能详细说明为什么你需要学习 C++ 吗?你将从事什么样的项目?

Visual Studio, with its intellisense and help is a pretty good platform to be learning a language on.

Visual Studio 及其智能感知和帮助是一个非常好的学习语言的平台。

回答by TSomKes

My own experience: my very first attempt at programming was C++ in VS. Learning the syntax was relatively straightforward, but coming to grips with compiling/linking/etc. was more painful until I moved out of the IDE. Those details are largely managed for/hidden from you.

我自己的经验:我第一次尝试编程是在 VS 中使用 C++。学习语法相对简单,但要掌握编译/链接/等。更痛苦,直到我搬出 IDE。这些细节主要是为您管理/隐藏的。

Having said that, if you're an experienced programmer, and especially if your goal is to work with C++ in VS (in a work or school environment, for example), than this is a viable quick-start option.

话虽如此,如果您是一位经验丰富的程序员,尤其是如果您的目标是在 VS 中使用 C++(例如,在工作或学校环境中),那么这是一个可行的快速入门选项。

回答by Broken_Window

For C++ I got used to Borland Compilers http://www.turboexplorer.com/. The differences between compilers are in the libraries they use (dlls and includes, but some of them are standard). I started with DevC++ (a free compiler http://www.bloodshed.net/devcpp.html) and I liked it too. The language is the same. But the best is to try different compilers and use the one you like the most.

对于 C++,我习惯了 Borland 编译器http://www.turboexplorer.com/。编译器之间的区别在于它们使用的库(dll 和包含,但其中一些是标准的)。我从 DevC++(一个免费的编译器http://www.bloodshed.net/devcpp.html)开始,我也喜欢它。语言是一样的。但最好的方法是尝试不同的编译器并使用您最喜欢的编译器。

And the best for learning C++ is starting witth console applications.

学习 C++ 的最佳方式是从控制台应用程序开始。

回答by bluebrother

To quote MSDNon managed c++:

在托管 C++ 上引用MSDN

Managed Extensions for C++ was created to extend the C++ language, allowing you to use the .NET Framework and target the common language runtime without having to learn a new programming language.

Managed Extensions for C++ 旨在扩展 C++ 语言,允许您使用 .NET Framework 并面向公共语言运行时,而无需学习新的编程语言。

Thus "Managed C++" is nothing that will help you learning C++. Besides, IMO the best way to learn a language is to learn its basics, not some extensions. This is not related to the compiler / IDE used. While VS might provide nice helpful features using a simple text editor with any command line compiler like g++is perfectly fine too.

因此,“托管 C++”并不能帮助您学习 C++。此外,IMO 学习语言的最佳方式是学习它的基础知识,而不是一些扩展。这与使用的编译器/IDE 无关。虽然 VS 可以使用简单的文本编辑器和任何命令行编译器(如g++)提供很好的有用功能,但也非常好。

回答by hhafez

If you want to learn just plain C++ and a bare minimum of anything else. I would suggest installing cygwin and gcc/g++. The reason I recoment cygwin is from the question it seems you using windows. Otherwise if you are using a *nix type system you should already have gcc.

如果您只想学习简单的 C++ 和最少的其他任何东西。我建议安装 cygwin 和 gcc/g++。我推荐 cygwin 的原因是你使用 windows 的问题。否则,如果您使用 *nix 类型系统,您应该已经拥有 gcc。

All you will need to do is create your c++ files in your favorite editor and compile. You will still have to learn how to use gcc and possibly make files (especially if you are making a non trivial project) but that is probably the bare minimum setup you could have for learning C++.

您需要做的就是在您喜欢的编辑器中创建您的 C++ 文件并进行编译。您仍然需要学习如何使用 gcc 并可能生成文件(特别是如果您正在制作一个非平凡的项目),但这可能是您学习 C++ 的最低限度的设置。