在Visual Studio中从头开始学习c++ ?

时间:2021-04-15 22:10:54

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..

谢谢你所有的建议。

11 个解决方案

#1


15  

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调用编译器来禁用),所以这不仅仅是微软的大、坏和不标准。,)

#2


8  

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->项目->Win32控制台应用程序)中获取微软的细节。

// 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++书籍中读取的代码。

#3


6  

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#、managed c++,以及real (unmanaged) c++,因此:

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

#4


3  

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学习是一个很好的选择,因为您可以直接进入代码中,而不必过多地考虑项目的配置。

#5


3  

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,它的智能感知和帮助是学习语言的一个很好的平台。

#6


3  

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/。

#7


2  

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.

我自己的经验:我在编程方面的第一次尝试是c++ in VS. Learning语法是相对简单的,但是要掌握编译/链接/等等。更痛苦的是,直到我离开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++(例如,在工作或学校环境中),那么这是一个可行的快速启动选项。

#8


0  

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和include,但有些是标准的)。我从DevC++(免费编译器http://www.bloodshed.net/devcpp.html)开始,我也很喜欢它。语言是一样的。但是最好是尝试不同的编译器并使用您最喜欢的编译器。

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

学习c++的最佳方法是启动witth控制台应用程序。

#9


0  

To quote MSDN on 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.

c++的托管扩展被创建用于扩展c++语言,允许您使用. net框架,并针对公共语言运行时,而不必学习新的编程语言。

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++。此外,在我看来,学习一门语言最好的方式是学习它的基础,而不是一些扩展。这与所使用的编译器/ IDE无关。使用一个简单的文本编辑器和任何命令行编译器(如g++), VS可以提供很好的功能。

#10


0  

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++所需要的最低设置。

#11


0  

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++的扩展和特性,而不是语言本身?

You should not confuse between managed C++ and VS. You can code unmanaged (true) C++ even in Visual Studio. Visual Studio is just an IDE.

您不应该混淆托管c++和非托管c++,甚至在Visual Studio中也可以编写非托管(true) c++。Visual Studio只是一个IDE。

If learning in VS is not recommended, what platform / IDE do you guys suggest? 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?

如果不建议在VS中学习,你们建议使用什么平台/ IDE ?编辑:谁能详细说明在编写非托管c++时VS将隐藏或管理什么?我真的需要学习一些东西,比如指针,垃圾收集和所有的底层语言的细节。VS是否对你抽象或隐藏这些东西?

VS like any other IDE will hide stuffs such as the compiling and linking stages from you. But it wont hide any language features from you. Yes you can learn pointers and other low level stuffs with VS. Unmanaged C++ does not support garbage collection. But if you are a beginner and you are not in a hurry, then the best way is to take a text editor, a compiler and a debugger and code. g++,gdb and emacs/vi will be a better substitution for VS for beginners. You will actually feel how things are compiled, linked and finally a binary is made. But it will take time and may require guidance to be up with the tools. With VS you can be up in minutes. If your objective is to learn C++ language syntax and features, then go ahead make a new empty VC++ project in VS and code.

与其他IDE一样,VS将隐藏诸如编译和链接阶段等内容。但它不会向您隐藏任何语言特性。是的,您可以通过与不受管理的c++相比,学习指针和其他低级的东西,它们不支持垃圾收集。但是,如果你是初学者,而且你不着急,那么最好的方法就是使用文本编辑器、编译器、调试器和代码。g++、gdb和emacs/vi对于初学者来说是更好的替代。你会真切地感受到事物是如何被编译、连接并最终形成二进制的。但这需要时间,可能需要指导才能使用这些工具。用VS你可以在几分钟内起床。如果你的目标是学习c++语言的语法和特性,那就在VS和代码中创建一个新的空的vc++项目。

#1


15  

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调用编译器来禁用),所以这不仅仅是微软的大、坏和不标准。,)

#2


8  

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->项目->Win32控制台应用程序)中获取微软的细节。

// 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++书籍中读取的代码。

#3


6  

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#、managed c++,以及real (unmanaged) c++,因此:

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

#4


3  

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学习是一个很好的选择,因为您可以直接进入代码中,而不必过多地考虑项目的配置。

#5


3  

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,它的智能感知和帮助是学习语言的一个很好的平台。

#6


3  

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/。

#7


2  

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.

我自己的经验:我在编程方面的第一次尝试是c++ in VS. Learning语法是相对简单的,但是要掌握编译/链接/等等。更痛苦的是,直到我离开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++(例如,在工作或学校环境中),那么这是一个可行的快速启动选项。

#8


0  

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和include,但有些是标准的)。我从DevC++(免费编译器http://www.bloodshed.net/devcpp.html)开始,我也很喜欢它。语言是一样的。但是最好是尝试不同的编译器并使用您最喜欢的编译器。

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

学习c++的最佳方法是启动witth控制台应用程序。

#9


0  

To quote MSDN on 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.

c++的托管扩展被创建用于扩展c++语言,允许您使用. net框架,并针对公共语言运行时,而不必学习新的编程语言。

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++。此外,在我看来,学习一门语言最好的方式是学习它的基础,而不是一些扩展。这与所使用的编译器/ IDE无关。使用一个简单的文本编辑器和任何命令行编译器(如g++), VS可以提供很好的功能。

#10


0  

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++所需要的最低设置。

#11


0  

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++的扩展和特性,而不是语言本身?

You should not confuse between managed C++ and VS. You can code unmanaged (true) C++ even in Visual Studio. Visual Studio is just an IDE.

您不应该混淆托管c++和非托管c++,甚至在Visual Studio中也可以编写非托管(true) c++。Visual Studio只是一个IDE。

If learning in VS is not recommended, what platform / IDE do you guys suggest? 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?

如果不建议在VS中学习,你们建议使用什么平台/ IDE ?编辑:谁能详细说明在编写非托管c++时VS将隐藏或管理什么?我真的需要学习一些东西,比如指针,垃圾收集和所有的底层语言的细节。VS是否对你抽象或隐藏这些东西?

VS like any other IDE will hide stuffs such as the compiling and linking stages from you. But it wont hide any language features from you. Yes you can learn pointers and other low level stuffs with VS. Unmanaged C++ does not support garbage collection. But if you are a beginner and you are not in a hurry, then the best way is to take a text editor, a compiler and a debugger and code. g++,gdb and emacs/vi will be a better substitution for VS for beginners. You will actually feel how things are compiled, linked and finally a binary is made. But it will take time and may require guidance to be up with the tools. With VS you can be up in minutes. If your objective is to learn C++ language syntax and features, then go ahead make a new empty VC++ project in VS and code.

与其他IDE一样,VS将隐藏诸如编译和链接阶段等内容。但它不会向您隐藏任何语言特性。是的,您可以通过与不受管理的c++相比,学习指针和其他低级的东西,它们不支持垃圾收集。但是,如果你是初学者,而且你不着急,那么最好的方法就是使用文本编辑器、编译器、调试器和代码。g++、gdb和emacs/vi对于初学者来说是更好的替代。你会真切地感受到事物是如何被编译、连接并最终形成二进制的。但这需要时间,可能需要指导才能使用这些工具。用VS你可以在几分钟内起床。如果你的目标是学习c++语言的语法和特性,那就在VS和代码中创建一个新的空的vc++项目。