Третья группа — различия между версиями

Материал из SEWiki
Перейти к: навигация, поиск
Строка 90: Строка 90:
 
== Smart-Pointers ==
 
== Smart-Pointers ==
  
scoped_ptr:http://www.boost.org/doc/libs/1_52_0/libs/smart_ptr/scoped_ptr.htm
+
scoped_ptr: http://www.boost.org/doc/libs/1_52_0/libs/smart_ptr/scoped_ptr.htm
 +
 
 
shared_ptr: http://www.boost.org/doc/libs/1_52_0/libs/smart_ptr/shared_ptr.htm
 
shared_ptr: http://www.boost.org/doc/libs/1_52_0/libs/smart_ptr/shared_ptr.htm

Версия 15:53, 30 ноября 2012

Общее

Задания

Компиляция

Сортировка слиянием

Выделение памяти

Расширяющийся массив

Обертка над FILE

String

Smart FILE

Streams

Наследуясь от класса OutputStream реализовать Иерархию классов FileOutputStream, StringOutputStream, ConsoleOutputStream имеющие соответствующую функциональность.

struct OutputStream
{
    virtual void print( std::string const& s ) = 0;

    virtual void print( int t ) 
    {
        char buff[16] = {};
        sprintf(buff, "%d", t);
        print(buff);
    }

    virtual void print( double t ) 
    {
        char buff[16] = {};
        sprintf(buff, "%f", t);
        print(buff);
    }

    virtual void flush() = 0;

    virtual ~OutputStream() {}
};


Rationals


// Rational.h

class Rational {

    Rational & operator+=( Rational const& b );

    Rational & operator-=( Rational const& b );

    Rational & operator/=( Rational const& b );

    Rational & operator*=( Rational const& b );

    Rational operator-() const;

    double to_double() const;

    int nom();
    int den();

};

ostream & operator<<(ostream & os, Rational const& r);
istream & operator>>(istream & is, Rational & r);

Rational  operator+( Rational a, Rational const& b );
Rational  operator-( Rational a, Rational const& b );
Rational  operator/( Rational a, Rational const& b );
Rational  operator*( Rational a, Rational const& b );

bool operator==( Rational const& a, Rational const& b );
bool operator!=( Rational const& a, Rational const& b );
bool operator<( Rational const& a, Rational const& b );
bool operator<=( Rational const& a, Rational const& b );
bool operator>( Rational const& a, Rational const& b );
bool operator>=( Rational const& a, Rational const& b );
~                                                                

Smart-Pointers

scoped_ptr: http://www.boost.org/doc/libs/1_52_0/libs/smart_ptr/scoped_ptr.htm

shared_ptr: http://www.boost.org/doc/libs/1_52_0/libs/smart_ptr/shared_ptr.htm