Main:

#include <iostream>
#include "color.h"
#include "String.h"


int _tmain()

{   
    Color czarny("czarny",2,3,4);
    czarny.print();
	



	system("pause");
	return 0;
}

String.cpp:


#include "String.h"




string::string(){str = 0; len = 0;
cout << "Konstruktor bezargumentowy string"<< endl;}

string::string(char * A)
{
	len=strlen(A);
	str = new char[len+1];
	strcpy(str,A);
	cout << "Konstruktor char* - argumentowy string"<< endl;
}

string::string(char A, int l)
{
	len=l;
	str = new char[len+1];
	for(int i=0;i<len;i++)
	str[i]=A;
	str[len]=0;
	cout << "Konstruktor char, int argumentowy string"<< endl;
}

string::~string()
{   if(str)
	delete []str;
str=NULL;
    cout << "destruktor string"<< endl;
}

string.h

#pragma once

#include <iostream>

using namespace std;


class string
{   
	 
	char *str;
	int len;

public:

	// konstruktory i destruktor

	string();           
	string(char *);
	string(char, int);
	~string();

	
	void print()
	{cout << "zawartosc pola str :" << str << endl;};

	
};

color.cpp

#include "color.h"


Color::Color()
{
	
	cout << "konstruktor bezargumentowy Color" << endl;
}

Color::Color(string p)
{
 nazwa=p;
 cout << "konstruktor string - argumentowy Color" << endl;
}

Color::Color(string p, int a, int s, int d)
{
        nazwa=p;
        R=a;
        G=s;
        B=d;
        cout << "kontruktor 4 - argumentowy Color" << endl;
}

Color::Color(int x, int y, int z)
{
	R=x;
	G=y;
	B=z;
	cout << "kontruktor 3 - argumentowy Color" << endl;
}

Color::~Color()
{
	cout << "destruktor Color" << endl;
}

void Color:: print()
{ cout << R << G << B << endl;
  nazwa.print();};

color.h

#pragma once
#include <iostream>
#include "String.h"

using namespace std;

class Color 
{
	int R,G,B;
	string nazwa;

public:

	// konstruktory i destruktor

	Color();
	Color(Tstring);
	Color(Tstring,int,int,int);
	Color(int,int,int);
	~Color();

	void print();

};

dla widocznego tworzenia obiektów w int main, wartosci R G B wyswietlaja się dobrze natomiast przy wyswietlaniu "Nazwiy" pokazują się jakieś krzaki - dlaczego? gdy usunę destruktor String to nazwa wyświetla się dobrze, ale pojawia się komunikat o błędzie.

Co z tym fantem zrobic?