delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/07/11:15:44

From: Hans-Bernhard Broeker <broeker AT acp3bf DOT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: C++, Multiple Files, Classes
Date: 7 Jan 2000 14:25:57 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 34
Message-ID: <854t1l$jta$1@nets3.rz.RWTH-Aachen.DE>
References: <3873FF7B DOT DFB48EA2 AT wt DOT net> <38751224 DOT 65715732 AT wt DOT net>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 947255157 20394 137.226.32.75 (7 Jan 2000 14:25:57 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 7 Jan 2000 14:25:57 GMT
User-Agent: tin/1.4-19991113 ("No Labels") (UNIX) (Linux/2.0.0 (i586))
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Aaron Chernosky <chernobl AT wt DOT net> wrote:
> Okay... that's fixed, have all the stuff in the same file (the class and
> the funcs):

That's wrong, again. You should *not* have the definitions of (non-inline)
methods in the file that you #include from other modules.

You should have the following:


--- MyClass.h ---
#ifndef MYCLASS_H
#define MYCLASS_H
class MyClass {
  public:
    MyClass();
    ~MyClass();
};

#endif

--- MyClass.cpp ---
#include "MyClass.h"

MyClass::MyClass() { }

MyClass::~MyClass() { }
----------------

And from 'main.cpp' or whatever it's called, #include "MyClass.h"

-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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