Help with Headers

This is a discussion on Help with Headers within the C++ Programming forums, part of the General Programming Boards category; Hi there. I want to know how to create and link new header files to my main cpp file, for ...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    84

    Help with Headers

    Hi there.

    I want to know how to create and link new header files to my main cpp file, for example:

    i make a class.h file, and in that .h file i have a class for example, and i want to like that .h file to my cpp file so i can use that class in the cpp file.

    is that possible?? if yes how can i do it??

    tks

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    266
    heres an example

    car.h
    Code:
    class car
    {
       char color;
       public:
       car();
       void honk();
       char get_color();
    };
    car.cpp
    Code:
    #include "car.h"
    #include <iostream>
    
    car::car()
    {
      color = 'b';
    }
    void car::honk()
    {
      cout << "bipbip";
    }
    char car::get_color()
    {
      return color;
    }
    
    int main()
    {
      car honda;
      car.honk();
    }
    Is this what you wanted to know?

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    84
    Yes it was, tks for ur help..

    solved

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 06-18-2005, 02:26 PM
  2. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  3. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM
  4. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 04:25 AM
  5. how do you handle all your headers?
    By mart_man00 in forum Linux Programming
    Replies: 0
    Last Post: 06-16-2003, 03:17 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21