Jump to content

Recommended Posts

Posted
#include<iostream>

#include<string>

#include<cstring>

#include <cstdlib>

using namespace std;

class sir

{

	char *q;

public:

	//constructor

	sir(char s[])

	{

		q=new char[strlen(s)+1]; //aloca spatiu de cat are nevoie

		strcpy(q, s); //se copie in q sirul sir

	}

	//constructor de copiere

	sir(sir &x)

	{

		q=new char[strlen(x.q)+1];

		strcpy(q, x.q);

	}

	void operator=(sir &x)

	{

		delete q;

		q=new char[strlen(x.q)+1];

		strcpy(q, x.q);

	}

	void afiseaza()

	{

		cout<<q<<" ";

	}

};

int main()

{

	sir a("MEMEMEME"), b("WOWWW"), c=a;

	a.afiseaza();

	b.afiseaza();

	c.afiseaza();

	a=b;

	a.afiseaza();

	b.afiseaza();

	system("PAUSE");

	return 0;

}

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.