[Job interview] C/C plus Programming

Source: Internet
Author: User
ArticleDirectory
    • 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 betweenParameterAndArgument?


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 CStructAnd a C ++Struct.
    • Write a snippet of code that will compile in C but not in C ++.
    • What is the differenceMallocAndOperator 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 ype (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: Valid tive 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.