[Job Interview] C/C plus plus Programming

來源:互聯網
上載者:User
文章目錄
  • C++ & C
  • Standard C/C++ Comparisons
  • Cruel comparisons

C++ & C
  • Can you declare a C struct that looks like a C++ class and somehow call member functions?
  • What is the difference between a parameter and an argument?


Standard C/C++ Comparisons

  • How can you make C code resemble C++ code? (i.e. write object oriented code with C)
  • State some differences between a C struct and a C++ struct.
  • Write a snippet of code that will compile in C but not in C++.
  • What is the difference between malloc and operator new?

Answer: The difference is really the return value and arguments each take. To begin with malloc is a function whereas new is an C++ operator. malloc returns a void pointer and it is the responsibility of the user to typecast to the appropriate data type whereas new returns object of type being allocated. malloc takes in number of bytes to be allocated as the parameter which is an integer (or size_t) whereas new takes the type of the datatype(can be a class as well). Bonus: It is generally not a good idea to mix C and C++ i.e. use malloc and use delete or use new and use free Item 3 : Effective C++

Cruel comparisons
  • Are C programmers better than C++ programmers?

Answer: This is really not an apple to apple comparision. Let us drop this question right here

  • Why are open source operating systems written in C instead of C++?

Answer:Performance is a factor rather than re usability.

  • What makes C more suitable for writing threaded apps than C++?

Answer: Performance again

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.