Технический форум

Технический форум (http://www.tehnari.ru/)
-   Помощь студентам (http://www.tehnari.ru/f41/)
-   -   Перегрузка new (http://www.tehnari.ru/f41/t106396/)

dimok5 16.01.2016 13:20

Перегрузка new
 
Помогите пожалуйста с задачей. С перегрузкой совсем не дружу.
Для созданного объекта а, разработанного класса - строка, реализовать перегрузку оператора new.
Код:

#include "stdafx.h"
#include <ios>
#include <malloc.h>
#include <stdlib.h>
#include <io.h>
#include <stdio.h>
#include <cstdlib>
#include <iostream>
using namespace std;
classCharStr{
protected:
        string Data;
public:
        CharStr()        {Data = "DefaultString";        };
        CharStr(string ini){Data = ini;        };
        CharStr(CharStr& a){Data = a.Data;};
        void Set(string newdata)        {Data = newdata;};
        string Get()        {return Data;};


--//перегрузка//--


int _tmain(intargc, _TCHAR* argv[])
{
        CharStr a, b;
        a.Set("The remember my");
        cout<< "A:" <<a.Get().c_str() <<endl;
        *a = '.';
        cout<< "A(new):" <<a.Get().c_str() <<endl;
        system("pause");
        return 0;
}



Часовой пояс GMT +4, время: 08:21.

Powered by vBulletin® Version 4.5.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.