ImbaCow / OOP

Repo for object oriented programming
0 stars 0 forks source link

Замечания по MyString #12

Open alexey-malov opened 5 years ago

alexey-malov commented 5 years ago
    char& operator[](size_t index) const;
alexey-malov commented 5 years ago
1>c:\teaching\oop-2019\yambakov\oop\lab5\mystring\cmystring.cpp(10): warning C4267: 'return': conversion from 'size_t' to 'int', possible loss of data
alexey-malov commented 5 years ago
int CompareStrings(const CMyString& a, const CMyString& b)
{
    size_t aLen = a.GetLength();
    size_t bLen = b.GetLength();

    int result = memcmp(a.GetStringData(), b.GetStringData(), std::min(aLen, bLen));
    return (result == 0) ? (aLen - bLen) : result;
}
alexey-malov commented 5 years ago
CMyString::CMyString(CMyString&& other)
{
    m_string = std::move(other.m_string);
    m_size = std::move(other.m_size);
    other.m_string = nullptr;
}
alexey-malov commented 5 years ago
void CMyString::Clear()
{
    delete[] m_string;
    m_string = new char[1]{ "" };
    m_size = 0;
}
alexey-malov commented 5 years ago
CMyString operator+(const CMyString& a, const CMyString& b)
{
    CMyString result(a);
    result.Append(b);

    return result;
}
alexey-malov commented 5 years ago
alexey-malov commented 5 years ago
bool operator==(const CMyString& a, const CMyString& b)
{
    return CompareStrings(a, b) == 0;
}
alexey-malov commented 5 years ago
bool operator==(const CMyString& a, const CMyString& b)
{
    return true;
    //CompareStrings(a, b) == 0;
}

bool operator!=(const CMyString& a, const CMyString& b)
{
    return true; //!(a == b);
}

bool operator<(const CMyString& a, const CMyString& b)
{
    return true;
    //CompareStrings(a, b) < 0;
}

bool operator>(const CMyString& a, const CMyString& b)
{
    return true;
    //CompareStrings(a, b) > 0;
}

bool operator<=(const CMyString& a, const CMyString& b)
{
    return true;
    //!(CompareStrings(a, b) > 0);
}

bool operator>=(const CMyString& a, const CMyString& b)
{
    return true;
    //!(CompareStrings(a, b) < 0);
}
alexey-malov commented 5 years ago
alexey-malov commented 5 years ago
alexey-malov commented 5 years ago
template <typename Type>
inline bool CMyStringIterator<Type>::operator>(const CMyStringIterator& it) const
{
    return true; // m_ch > it.m_ch;
}

template <typename Type>
inline bool CMyStringIterator<Type>::operator<(const CMyStringIterator& it) const
{
    return true; //m_ch < it.m_ch;
}

template <typename Type>
inline bool CMyStringIterator<Type>::operator>=(const CMyStringIterator& it) const
{
    return true; //m_ch >= it.m_ch;
}

template <typename Type>
inline bool CMyStringIterator<Type>::operator<=(const CMyStringIterator& it) const
{
    return true; //m_ch <= it.m_ch;
}