You are here:

C++/Header file



I have a question about the below,can you tell me whats the problem with it that every time i compile it,it shows me this error:"fatal error C1083: Cannot open include file: 'GradeBook.h': No such file or directory"
what should i do for taking away this error?

#include <iostream>
using std::cout;
using std::endl;

#include "GradeBook.h" // include definition of class GradeBook

// function main begins program execution
int main()
  // create two GradeBook objects
  GradeBook gradeBook1( "CS101 Introduction to C++ Programming" );
  GradeBook gradeBook2( "CS102 Data Structures in C++" );

  // display initial value of courseName for each GradeBook
  cout << "gradeBook1 created for course: " << gradeBook1.getCourseName()
     << "\ngradeBook2 created for course: " << gradeBook2.getCourseName()
     << endl;
  return 0; // indicate successful termination
} // end main


The error is self-explanatory - the preprocessor can not find the file "GradeBook.h"

Generally, it is necessary to tell the preprocessor where to look for header file if it is not placed in the same directory as the file containing the #include directive or a standard system directory.

You could:
a. place the file "GradeBook.h" in the same directory as the file with main()
b. use a relative path specifier eg. #include "../my_include_files/GradeBook.h"
c. use a complete path specifier eg. #include "/usr/home/me/src/my_include_files/GradeBook.h"
d. tell the preprocessor which additional directories are to be searched to locate header files. How to do this is implementation-specific; you need to look at the documentation for the compiler that you are using. In case of the microsoft compiler that you seem to be using, see:

also note: on posix systems, file names are case-sensitive. GradeBook.h" is different from "gradebook.h"


All Answers

Answers by Expert:

Ask Experts




my primary areas of interest are generic and template metaprogramming, STL, algorithms, design patterns and c++11. i would not answer questions about gui and web programming.


about 15 years or so

post graduate engineer

©2016 All rights reserved.