Author Topic: How to compile .h with a .cpp file  (Read 4957 times)

Offline pisco

  • Multiple posting newcomer
  • *
  • Posts: 10
How to compile .h with a .cpp file
« on: January 13, 2010, 03:55:58 pm »
Hey guys
here is my prob. I have two file. One is a .h and the other is a .cpp file:
Quote
// Grundstueck.cpp (bspl0048.cpp)
#include <iostream>
#include <cstring>
#include "bspl0048a.h"   // Grundstueck.h
using namespace std;

Grundstueck::Grundstueck() {
}

Grundstueck::~Grundstueck() {
}

void Grundstueck::speichereGrunddaten(const char *n,
               int f, int st, int g) {
   strncpy(gemarkung, n, 29);
   flur=f;
   flurstueck=st;
   groesse=g;
   sachwert=static_cast<float>(g)*180;
}

void Grundstueck::zeigeGrunddaten() const {
   cout << "\n" << "Gemarkung:  " << gemarkung << "\n"
         << "Flur:       " << flur << "\n"
         << "Flurstueck: " << flurstueck << "\n"
         << "Groesse:    " << groesse <<  "\n"
         << "Wert:       " << sachwert;
}
and
Quote
// Grundstueck.h (bspl0048.h)
#ifndef _GRUNDSTUECK_
#define _GRUNDSTUECK_

class Grundstueck {
   public:
      Grundstueck();
      ~Grundstueck();
      void speichereGrunddaten(const char *n,
                      int f, int st, int g);
      void zeigeGrunddaten() const;
   private:
      char gemarkung[30];
      int flur, flurstueck, groesse;
   protected:
      float sachwert;
};

#endif

I am a total newbie in code::blocks so here is my question:
How can I compile those two file to one .exe file?

I thank you in advance for your time and attention and look forward to your replys.

greetz pisco

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: How to compile .h with a .cpp file
« Reply #1 on: January 13, 2010, 04:09:49 pm »
How can I compile those two file to one .exe file?
Setup a project, add both files to the project hit compile and you are done. Consult the C::B documentation (http://www.codeblocks.org/docs/main_codeblocks_en.html) accordingly.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline pisco

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: How to compile .h with a .cpp file
« Reply #2 on: January 13, 2010, 08:38:38 pm »
thx thx thx for your reply MortenMacFly

could you please explain me the exact steps ,because I have not enough time to read the documentation... :(

greetz pisco
« Last Edit: January 13, 2010, 10:29:42 pm by pisco »