Hi, ich habe ein Problem. Nämlich wollte ich einem Freund eine Einführung in C++ schreiben und bin dabei auf ein Problem gestoßen: Ein (bestimmtes) Objekt wird anscheinend garnicht erzeugt.

Hier der Code:

TestKlasse.hpp
Code:
#ifndef TESTKLASSE_H 
   #define TESTKLASSE_H
class Testklasse
{
   private:
      const int Wert;                 
      const int Wert2;                 
      static const int StandardWert;        
      static const int StandardWert2;       
      static const int StandardKonstruktorwert;     
      static const int StandardKonstruktorwert2;    
      static int IDs;                   
      int meineID;                         

      void InfosPrint(bool copy=false);

      void IstKopie(bool copy=false);
   public:
      Testklasse();
      Testklasse(const int BenutzerWert, const int BenutzerWert2=StandardKonstruktorwert2);
      Testklasse(const Testklasse& Quelle);
      Testklasse& operator=(const Testklasse&);
      void SagWas() const;
      ~Testklasse();
};

const int Testklasse::StandardWert     = 10;            
const int Testklasse::StandardWert2    = StandardWert*2;    
const int Testklasse::StandardKonstruktorwert  = -6;   
const int Testklasse::StandardKonstruktorwert2 = -12; 

int Testklasse::IDs                = 0;             
#endif
TestKlasse.cpp
Code:
#include "Testklasse.hpp"
Testklasse::Testklasse():
                    Wert (StandardWert) ,
                    Wert2(StandardWert2),
                    meineID(++IDs)
{
    printf("ID: %i %p\n", meineID,this);
    InfosPrint();
}

Testklasse::Testklasse(
                     const int BenutzerWert ,
                     const int BenutzerWert2
                    ):
                    Wert (BenutzerWert),
                    Wert2(BenutzerWert2),
                    meineID(++IDs)
{
    printf("ID: %i %p\n", meineID,this);
    InfosPrint();
}

Testklasse::Testklasse(const Testklasse& Quelle):
                    Wert (Quelle.Wert),
                    Wert2(Quelle.Wert2),
                    meineID(++IDs)
{
    printf("ID: %i %p\n", meineID,this);
    InfosPrint(true);
}

Testklasse& Testklasse::operator=(const Testklasse& target)
{
    Testklasse myTemp(target);

/*
    const int tarVal1=target.Wert, tarVal2=target.Wert2;
    //printf(" Wert 1: %i (100% COPY)\n",tarVal1);
    //printf(" Wert 2: %i (100% COPY)\n\n",tarVal2);

    printf("COPY-KON2\nID: %i\n", meineID);
    InfosPrint(true);
*/
    return *this;//::Testklasse(tarVal1, tarVal2);
}

void Testklasse::InfosPrint(bool copy)
{
    for(int i=0; i<3; ++i)
    {
        if      (i==0)
        {
            printf(" Wert %i: %i ",i+1, Wert);
            IstKopie(copy);
            switch(Wert)
            {
                case StandardWert:
                    printf(" DEFAULT)\n");
                    break;
                case StandardKonstruktorwert:
                    printf(" CONSTRUCTOR)\n");
                    break;
                default:
                    printf(" USER)\n");
            };
        }
        else if (i==1)
         {
            printf(" Wert %i: %i ",i+1, Wert2);
            IstKopie(copy);
            switch(Wert2)
            {
                case StandardWert2:
                    printf(" DEFAULT)\n");
                    break;
                case StandardKonstruktorwert2:
                    printf(" CONSTRUCTOR)\n");
                    break;
                default:
                    printf(" USER)\n");
            };
        }
    }
        printf("\n");
}

void Testklasse::IstKopie(bool copy)
{
    if(copy)
        printf("(COPY,");
    else
        printf("(ORGINAL,");
}

void Testklasse::SagWas() const
{
    printf("%i: Ich lebe!\n  (%p)\n",meineID,this);
}

Testklasse::~Testklasse()
{
    SagWas();
}
Programm.cpp
Code:
#include <iostream>
#include <stdio.h>
#include "cInitList.cpp"
int main()
{
   Testklasse A();
   Testklasse B(12);
   Testklasse C(2,6);
   Testklasse *D;
   *D=B;
   Testklasse E;
   B.SagWas();
   //Was ist mit A los?
   //A.SagWas();
}
Die Ausgabe verwirrt mich, es scheint so, als würde A garnicht existieren.
Wenn ich A.SagWas(); entkommentiere, wird mir der Fehler um die Ohren gehauen:
request for member ‘SagWas’ in ‘A’, which is of non-class type ‘Testklasse()