1

As in the title I have a program containing of 3(5) files main.cpp, Kessel.h, Kessel.cpp, other two are non important

My problem: When I change code in Kessel.cpp it does not get registered when i compile the program ... so I tried making an obvious error by deleting a ';' and it just says "Target is up to date." I'm using Code::Blocks btw.

Header Kessel.h:

#ifndef _KESSEL_H_
#define _KESSEL_H_

class Kessel {
    private:
        double KesselTemperatur;
        double KesselInhalt;
        int XKoord;
        int YKoord;
        int Breite;
        int Hoehe;
        char *Name;

   public:
        Kessel(const char *Name, int X, int Y, int B=150, int H=150, double 
        Inhalt=0, double Temperatur=0);
        ~Kessel();
        void Fuellen(double T2, double V2);
};

#endif // KESSEL_H

Source Kessel.cpp:

#include "Kessel.h"
#include "WinAdapt.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sstream>
#include <iostream>

void Kessel::Fuellen(double T2, double V2){

    double T1 = Kessel::KesselTemperatur;
    double V1 = Kessel::KesselInhalt;

    KesselTemperatur = (T1*V1+T2*V2)/(V1+V2);
    KesselInhalt+=V2;
}


Kessel::Kessel(const char *Name, int X, int Y, int B=150, int H=150, double             
Inhalt=0, double Temperatur=0)
: XKoord{X}, YKoord{Y}, Breite{B}, Hoehe{H}, KesselInhalt{Inhalt},         
KesselTemperatur{Temperatur}
{
    Kessel::Name = new( char[ strlen( Name )+1 ] );
    strcpy( Kessel::Name, Name );
}


Kessel::~Kessel(){
    delete []Name;
}

and main.cpp:

#include "Kessel.h"
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <ctime>

//Kessel k1("Kessel1",10,10,130,100,10,30);
//Kessel k2("Kessel2",10,200,130,130,10,70);
//Kessel k3("Kessel3",200,10,10,70);
//Kessel k4("Kessel4",400,10);

When I un-comment Kessel k1 I get the error:

undefined reference to 'Kessel::~Kessel()'

Needs help pls :/

Erik Weber
  • 53
  • 1
  • 4
  • 1
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Ben Steffan Jun 26 '17 at 16:56
  • 4
    It would seem that Kessel.cpp is not in your project dependencies (at least not correctly). – WhozCraig Jun 26 '17 at 16:56
  • Is `Kessel.cpp` part of the Code::Blocks project? It's not only in the same directory on the disk, but in the actual project? – Some programmer dude Jun 26 '17 at 16:57
  • 1
    But can it run in less than 12 parsecs? – user4581301 Jun 26 '17 at 17:27

1 Answers1

2

I solved the problem by right clicking on the Kessel.cpp Headline in Code::Blocks then

properties -> Build -> checking the "DebugWindows" under "Belongs in targets"

Shakiba Moshiri
  • 21,040
  • 2
  • 34
  • 44
Erik Weber
  • 53
  • 1
  • 4