473,382 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to use my .h file in my spearate .cpp file?

I've been getting back into programming, specifically c++, and I have a question about using some old class files I had made. How do I use them in a normal program? I have my class files named filename.h (not actually filename) so when I get to the main program I tried using the #include <filename.h> but it doesn't seem to work.
Jan 11 '11 #1
3 1751
horace1
1,510 Expert 1GB
What errors do you get?
You have to be careful about about what you put in header files, e.g. putting member function definitions (code) can lead to multiple definitions at link time etc.
for a tutorial on the subject of class code and header files see
http://www.learncpp.com/cpp-tutorial...-header-files/
Jan 11 '11 #2
weaknessforcats
9,208 Expert Mod 8TB
#include <filename.h> tells the preprocessor to look for filename.h in ne of the "standard places".

These "standard places" are a series of filepaths you have specified as to where yur header files are located.

Look in yur compiler documentation about how to specify additional include directories.
Jan 12 '11 #3
Banfa
9,065 Expert Mod 8TB
Or alternatively use #include "filename.h" which in most implementations is defined as searching the same directory as the current file and then the same list of standard places searched by #include <filename.h> for the file.
Jan 13 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Russell E. Owen | last post by:
At one time, mixing for x in file and readline was dangerous. For example: for line in file: # read some lines from a file, then break nextline = readline() # bad would not do what a naive...
0
by: REM | last post by:
I have some problems. It's dilemma between BLOB, BFILE and takes care of file on file system. What it's advantage?? I import some PDF document in BLOB filed in my database. It's about 1000...
1
by: Daniel Cardoso | last post by:
I don't know what else to try - In my asp.net app, when the file name has Windows-1252 characters (like ã and ç), these characters appear, each one, as two strange characters in the file name label...
19
by: **Developer** | last post by:
When I get the image from the file the file remains locked so the Delete fails with a "used by another process" So I tried using a clone and disposing the obtained image. But that didn't fix...
0
by: suryanector | last post by:
anybody knows source code for programs using Index file, inverted file operations, usage of B and B++ trees in C++ language plz send them.
10
by: vunet.us | last post by:
What is the workaround of passign a parameter to any included asp file: <!-- #Include File="file.asp" --> This obviously does not work: <!-- #Include File="file.asp?id=123" --> Thank you
1
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
Hi, Anyone know of a folder equivalent to File.Exist(file) ? regards Jesper.
2
by: charlesbritto | last post by:
A C++ program for counting individual string in a text file using file handling functions., for ex: if the text file contains, am a boy,am studying +2,am from chennai Now the result shoud...
8
by: raylopez99 | last post by:
I have the latest version of Visual Studio 2008 Professional, which allows you to create resource files (this is the .resx file, no?), unlike the Express version, which does not. I am trying to...
3
by: ndoe | last post by:
how to make a paragraph from file to file like this e.g data.txt i want eat some pizza with
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.