C ++有多少适用于C? [英] How much of C++ applies to C?

查看:84
本文介绍了C ++有多少适用于C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在是C#开发人员。因此,我熟悉类和OOP概念。



即将推出的项目可能要求软件用ANSI C编写。



如果我参加C ++培训课程,有多少适用于C?



换句话说,当我在C ++中获得指针,内存分配等的训练,在C中是否相同?



或者我应该尝试在ANSI C中找到一门课程吗?

解决方案

请参阅: http:// en。 wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B [ ^ ]。



如果你学好了C ++,在学习了C的范围和一些C特性之后,你可以认为你已经知道了C语言,就像C和C ++中表现不同的构造一节中列出的那样上面引用的文章。



欲了解更多信息: http://bit.ly/1j0Pe4c [ ^ ]。



-SA


如果您的项目仅限于ANSI C,除非您也知道C和C ++重叠的地方,否则知道C ++将无济于事。 C编译器会抱怨在C ++中有效的东西。



一些比较明显的差异:



1.没有bool(取决于编译器)

2.没有类

3.没有成员函数

4.必须声明局部变量在函数范围的开头。



例如,以循环。



这在C ++中没问题:



  for  int  i =  0 ; i<  10 ; i ++)





ANSI C预计:



  int  i; 
for (i = 0 ; i< 10 ; i ++)





你最好先学习C语言。没有什么可学的。当你学习C ++时,一切都会继续发展 - 你会知道差异。


C ++是C语言的超集。最初Bjarne Stroustrup创建了C ++作为向C语言添加类的方法。因此,C ++诞生了。



所以如果你了解C ++就知道C。

I'm a C# developer now. As such, I'm familiar with classes and OOP concepts.

An upcoming project may require the software to be written in ANSI C.

If I were to take a C++ training course, how much of that would apply to C?

In other words, when I get the training for pointers, memory allocation, etc in C++, will that be the same in C?

Or should I try to find a course in ANSI C instead?

解决方案

Please see: http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B[^].

If you learned C++ well, you can consider that you already know C, after learning the scope of C and some C peculiarities, like those listed in the section "Constructs that behave differently in C and C++" of the article referenced above.

For more information: http://bit.ly/1j0Pe4c[^].

—SA


If your project is restricted to ANSI C, knowing C++ won't help you unless you also know where C and C++ overlap. The C compiler will complain for things otherwise valid in C++.

Some of the more obvious differences:

1. no bool (depends on compiler)
2. no classes
3. no member functions
4. local variables must be declared at the start of function scope.

Take the for loop, for example.

This is okay in C++:

for (int i = 0; i < 10; i++)



ANSI C expects this:

int i;
for (i = 0; i < 10; i++)



You might be better off learning C first. There's less to learn. Everything will carry forward when you learn C++ - and you'll know the differences.


C++ is a superset of the C language. Originally Bjarne Stroustrup created C++ as a way to add classes to C. And as such, C++ was born.

So if you know C++ you know C.


这篇关于C ++有多少适用于C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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