Header File

How to use an additional Header File?

Page 1 of 1

4 Replies - 971 Views - Last Post: 18 May 2009 - 12:26 PM Rate Topic: -----

#1 bita  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 190
  • Joined: 21-April 09

Header File

Posted 18 May 2009 - 09:39 AM

I have wrote a class named "Gradebook",and My question is about how to linking GradeBook class's object code with c++ standard object code and main function's object code
i dont know how to use #include"GradeBook.h" in my code,becuase everytime i compile the code it gives me this error:" Cannot open include file: 'GradeBook.h'"

Here is the code:

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

#include "GradeBook.h" 


int main()
{
   
   GradeBook gradeBook1( "CS101 Introduction to C++ Programming" );
   GradeBook gradeBook2( "CS102 Data Structures in C++" );

   cout << "gradeBook1 created for course: " << gradeBook1.getCourseName()
	  << "\ngradeBook2 created for course: " << gradeBook2.getCourseName() 
	  << endl;
   return 0; 
}


Is This A Good Question/Topic? 0
  • +

Replies To: Header File

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4307
  • View blog
  • Posts: 12,088
  • Joined: 18-April 07

Re: Header File

Posted 18 May 2009 - 10:43 AM

First tip is to make sure that all your #include statements are together, just makes things easier to read.

Secondly, have you created GradeBook.h in a separate file and made sure that file was included in the project?

What compiler are you using? VC++ express?
Was This Post Helpful? 1
  • +
  • -

#3 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1137
  • View blog
  • Posts: 7,099
  • Joined: 07-September 06

Re: Header File

Posted 18 May 2009 - 10:43 AM

You need to have a Gradebook.h file which contains the class definition information for your Gradebook.cpp class. Right now I am assuming that you have a Gradebook.cpp file and don't have a .h file.
Was This Post Helpful? 1
  • +
  • -

#4 bita  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 190
  • Joined: 21-April 09

Re: Header File

Posted 18 May 2009 - 11:15 AM

View PostMartyr2, on 18 May, 2009 - 09:43 AM, said:

First tip is to make sure that all your #include statements are together, just makes things easier to read.

Secondly, have you created GradeBook.h in a separate file and made sure that file was included in the project?

No,could you plz tell me how can i do this?i have written the code but don't know how to include it in the project

What compiler are you using? VC++ express?

visual studio 2008

Was This Post Helpful? 0
  • +
  • -

#5 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 966
  • Joined: 09-May 09

Re: Header File

Posted 18 May 2009 - 12:26 PM

.h is a header file and is found at the top left
.cpp is where your objects are set, bottom left

when u make a class u will have both of these files, just include the header file in ur main.

:) Hope this helps
Kevin

.h is a header file and is found at the top left
.cpp is where your objects are set, bottom left

when u make a class u will have both of these files, just include the header file in ur main.

:) Hope this helps
Kevin

This post has been edited by deery5000: 19 May 2009 - 03:28 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1