Question

Q11: With the use of an example for each, answer the following questions on C++ header files: 1- What is the purpose of a C++ header file? Your explanation should include reference to typical header file content. 2-How is it possible to avoid multiple inclusions of the same file? 3- What are the benefits of conditional compilation? (2 marks)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. Header files contain definitions of Functions and Variables, which is imported or used into any C++ program by using the pre-processor #include statement.

The purpose of C++ if we want to use any function in our C++ program then first we need to import their definition from C++ library, for importing their declaration and definition we need to include header file in program by using #include. Header file include at the top of any C++ program.

For example if we use clrscr() in C++ program, then we need to include, conio.h header file, because in conio.h header file definition of clrscr() (for clear screen) is written in conio.h header file. C I Chegg.com ぐ C ⓘ cpp.sh x e G C++ header files withe x vO Header Files in C++. Sit G c.. online code reader × y D c++ shel

3. Benifit of conditional compilation are

By conditional compile I mean using #ifdefs to only compile certain bits of code in certain conditions. The #defineds themselves may be in either a common header file

  • header guards
  • conditional implementationdebug specific checks
  • per suggestion: extern "C" { and } so that the same headers may be used by the C++ implementation and by the C clients of the API

2.

  1. There are many different platforms that I use.
  2. I wonder if there is a simple solution, i.e., without using cmake, etc.
  3. I also use cross compilation for coprocessors.
  4. I want the flags used in compilation of the utility functions to be same as the flags used in compilation of user codes.

2. it is possible to avoid multiple inclusion of same file :

  1. There are many different platforms that can be use.
  2. wonder if there is a simple solution, i.e., without using cmake, etc.
  3. also use cross compilation for coprocessors.
  4. want the flags used in compilation of the utility functions to be same as the flags used in compilation of user codes.
Add a comment
Know the answer?
Add Answer to:
With the use of an example for each, answer the following questions on C++ header files:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ must use header files and implementation files as separate files. I’ll need a header file,...

    C++ must use header files and implementation files as separate files. I’ll need a header file, implementation file and the main program file at a minimum. Compress these files into one compressed file. Make sure you have adequate documentation. We like to manipulate some matrix operations. Design and implement a class named matrixMagic that can store a matrix of any size. 1. Overload the addition, subtraction, and multiplication operations. 2. Overload the extraction (>>) and insertion (<<) operators to read...

  • Programming Assignment 1 Structures, arrays of structures, functions, header files, multiple code files Program description: Read...

    Programming Assignment 1 Structures, arrays of structures, functions, header files, multiple code files Program description: Read and process a file containing customer purchase data for books. The books available for purchase will be read from a separate data file. Process the customer sales and produce a report of the sales and the remaining book inventory. You are to read a data file (customerList.txt, provided) containing customer book purchasing data. Create a structure to contain the information. The structure will contain...

  • Answer the following questions about readers and writers Is it possible for multiple readers to access...

    Answer the following questions about readers and writers Is it possible for multiple readers to access the same file simulataneously? Is it possible for multiple writers to access the same file simulataneously? Is it possible for multiple writers to access different files simulataneously? Why is it important to implement mutual exclusion in a reader/writer system? Is it possible for starvation to occur in a reader/writer system?

  • C++ HTML files use tags enclosed in angle brackets to denote formatting instructions. For ex- ample,...

    C++ HTML files use tags enclosed in angle brackets to denote formatting instructions. For ex- ample, indicates bold, indicates italics, etc. If a web browser is displaying an HTML document that contains ‘<’ or ‘>’ then it may mistake these symbols for tags. This is a common problem with C++ files, which contain many <’s and >’s. For example, the line “#include ” may result in the browser interpreting as a tag. To avoid this problem, HTML uses special symbols...

  • do numbers 4-8 4. Given any directory, use the Is command to display: • all files...

    do numbers 4-8 4. Given any directory, use the Is command to display: • all files and sub-directories starting with the letter "D" (note do not list anything in any sub-directory) • its immediate sub-directories (sub-directories only, and no other ordinary files) its immediate hidden sub-directories only - take a screenshot (#3-3) that clearly shows the command and the result. 5. Assume that the following files are in the working directory: $ ls intro notesb ref2 section 1 section3 section4b...

  • Section C (45% ) : Case Analysis (The tips in questions are for reference, they ARE NOT specific questions requiri...

    Section C (45% ) : Case Analysis (The tips in questions are for reference, they ARE NOT specific questions requiring u to answer, to do the narrow the legal issues, use the related legal sources, which may include WTO rules and WTO case law, to support your opinion. Try to be logic and critical in writing your answer.) se analysis, you should Section B(20%): Discussion 6.Your understanding of national treatment principles under WTO( the content, exception, typical cases to support...

  • Title: ER Operations Manager Used the files attached to answer the following Questions: o Use this Excel file C 3 and C 4 Excel file.xlsx o Use this file to submit your work C4 Part IIdocx Questi...

    Title: ER Operations Manager Used the files attached to answer the following Questions: o Use this Excel file C 3 and C 4 Excel file.xlsx o Use this file to submit your work C4 Part IIdocx Question 2: Multiple Regression: Effect of Age and General Health Status Score on Total ER Cost. 1. Purpose 2. Importance 3. Variables 4. Sample Size 5. Hypothesis 6. Methodology 7. Findings 8. Interpretations/Implications ting: Monthly Patient Volume. Question 3: Forec Scenario: You are the...

  • C++ project we need to create a class for Book and Warehouse using Book.h and Warehouse.h header ...

    C++ project we need to create a class for Book and Warehouse using Book.h and Warehouse.h header files given. Then make a main program using Book and Warehouse to read data from book.dat and have functions to list and find book by isbn Objectives: Class Association and operator overloading This project is a continuation from Project 1. The program should accept the same input data file and support the same list and find operations. You will change the implementation of...

  • in C++ 1. Answer the following questions: a) 2 pts] Explain why it is important to...

    in C++ 1. Answer the following questions: a) 2 pts] Explain why it is important to indent code. What happens if code is not indented? b) 2 pts) Explain how you can prevent the unintended use of garbage values? c) (2 pts] Give one reason why you should use the keyword const when dealing with constant values. Make sure to explain what could happen if you fail to use this keyword. d) 2 pts) Give an example where simply declaring...

  • .Your solution must include header, implementation file, and test files .In C++ write a code to...

    .Your solution must include header, implementation file, and test files .In C++ write a code to Consider a graphics system that has classes for various figures rectangles, squares, triangles, circles, and so on. For example, a rectangle might have data members for Height, Width and center point, while a square and circle might have only a center point and an edge length or radius. In a well-designed system, these would be derived from a common class, Figure. You are to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT