www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/01/19:40:58

From: kagenin AT usa DOT net (Kagenin)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: design question
Date: Thu, 01 Apr 1999 06:36:35 GMT
Message-ID: <37031294.14815147@news.jps.net>
References: <E5119E9B3D7E6103 DOT 0C2B744CC0FAB02E DOT C83C40393E95C2F8 AT library-proxy DOT airnews DOT net>
X-Newsreader: Forte Free Agent 1.11/32.235
NNTP-Posting-Host: 209.142.59.220
X-Original-NNTP-Posting-Host: 209.142.59.220
X-Trace: 1 Apr 1999 07:00:07 -0800, 209.142.59.220
Lines: 39
X-Original-NNTP-Posting-Host: 209.63.224.240
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Matthew Heyman <kay DOT heyman AT airmail DOT net> was feeling all groovy on Wed,
31 Mar 1999 22:34:11 +0000 when they posted 
:
>Hello  
>	I was recently messing with a program I was writing, and was wondering
>if there was any worth in breaking it up into smaller .cpp files with
>very specific stuff, IE one for keyboard commands, one for various other
>stuff.   Is it wise to do this, or is it just a preferential thing?   I
>was also wondering how to actually implement functions from other .cpp
>files into the main file.  I tried a direct cut-paste into a second
>file, but ended up with a bunch of errors.  I'm not sure how to do it in
>the first place, and that could be my problem. Any thoughts, pointers,
>or ideas? 
>
>Matthew Heyman

The more modular your project is, the better.

Try this.

Put related functions, or a full class interface, or all your structs
and enums and stuff into their own header file.  Call it myfile.h.
(don't forget the multiple inclusion guards!)

Give a definition for all the stuff in myfile.h in a file called
myfile.cpp.  Have myfile.cpp #include "myfile.h".  Compile this with
-c (compile only, don't link).

In a file that has to use these functions, #include the header file,
and on the command line, throw in myfile.o somewhere.

This is called modular compilation.  It's how you use functions in
other source files.  This, of course is an overly simplistic model,
but it works.

Kagenin
---
"When the Going gets Weird, the Weird turn Pro"
-Hunter S. Thompson

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019