Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-03-2004, 01:01 PM   #1
LQ Newbie
Registered: Mar 2004
Posts: 3

Rep: Reputation: 0
compiling .h and .cpp files with g++

my problem is i have 2 header files and 2 cpp files. What should i type in the command line using g++ so that all these files could be successfully compiled?

Translator.h(abstract class declaration) is used in TextTranslator.h as TextTranslator.h is a derived class. Also, TextTranslator.cpp uses TextTranslator.h. Finally the main() lies in test.cpp. I am facing errors if i give the command:
g++ -g test.cpp -o test.

Do advise on the best course of action even if it means redesigning inheritance pattern and code.

I have 5 files in all :
1. test.cpp
int main()
ifstream examplefile("readme.txt");
TextTranslator tt(examplefile);

2. TextTranslator.cpp
TextTranslator :: TextTranslator(){
TextTranslator :: TextTranslator(ifstream examplefile){
if (! examplefile.is_open())
cout << "Error opening file";
exit (1);
void TextTranslator :: translation(ifstream examplefile)
ofstream outfile("readme.xml");
outfile << "<Document>\n";
outfile << examplefile.rdbuf();
outfile << "\n</Document>";

3. TextTranslator.h
class TextTranslator : public Translator
TextTranslator(ifstream examplefile);

4. Translator.h
class Translator {
public :
void translation();

5. readme.txt - a text file that is to be read and processed
Old 03-03-2004, 01:47 PM   #2
Registered: Feb 2004
Posts: 40

Rep: Reputation: 15
Post the errors you are getting and I can try and work them out with you.
Old 03-03-2004, 02:23 PM   #3
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

And trying to post 3 times in the wrong forum is clearly against the rules. Please do not do it again.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
problems with compiling kopete (/lib/cpp error) mac1234mac Programming 1 09-14-2005 01:26 PM
gcc header files and cpp files? EchO Linux - Software 3 03-01-2005 01:14 AM
/lip/cpp error when compiling mep]-[isto Linux - Newbie 1 12-22-2003 06:44 AM
Problems when trying to compile cpp files using qt headers siphiuel Linux - Software 2 08-12-2003 04:41 AM
Problems when trying to compile cpp files using qt headers siphiuel Linux - Software 2 08-10-2003 07:10 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:33 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration