Solved

Seperate implementation/header files

Posted on 1998-12-22
5
208 Views
Last Modified: 2011-09-20
Hi,
I'm using g++ and can't find the right flags/procedure to compile/use a class I wrote with seperate header and implementation files.
0
Comment
Question by:bod_1
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:sosedada
ID: 1180856
Is this a template class?
0
 

Accepted Solution

by:
nbell earned 50 total points
ID: 1180857
The following is a make file which can be used on a UNIX system to compile with g++ (you can of course issue the same commands from the command line):

# make file comment

executablefilename: source1.o source2.o cpstring.o
      g++ -o executablefilename source1.o source2.o cpstring.o
source2.o: source2.cpp
      g++ -c source2.cpp
source1.o: source1.cpp
      g++ -c source1.cpp
cpstring.o: cpstring.cpp
      g++ -c cpstring.cpp


as far as the header files go, you will have them #included in your .cpp files.
0
 

Expert Comment

by:nbell
ID: 1180858
As an addendum to my answer, if you decide to use a make file they must follow a strict format which includes tabs which did not show up in my copy/paste.
0
 
LVL 1

Expert Comment

by:sosedada
ID: 1180859
The above makefile is very limited.  It doesn't handle include files in different directories, libraries, templates, or any compiler options.
0
 

Author Comment

by:bod_1
ID: 1180860
Ah, that's perfect.
Thanks nbell.
sosedada, no, it's just a regular class.  Before I asked the question I waded through a few of the previous ones and it saw something about template classes being some sort of a special exception but nope, just a plain old class.
Thanks guys.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now