From 157bcf4af8c94a2f0deb4efb209975c2f0eb35a6 Mon Sep 17 00:00:00 2001 From: Damimani Date: Tue, 3 Nov 2026 20:12:31 +0100 Subject: [PATCH] fixed --- feladat5/feladat5/CMyString.cpp | 111 ++++++++++++++++++++++- feladat5/feladat5/CMyStringException.cpp | 108 ---------------------- 2 files changed, 110 insertions(+), 109 deletions(-) diff --git a/feladat5/feladat5/CMyString.cpp b/feladat5/feladat5/CMyString.cpp index 8b09439..57d372d 100644 --- a/feladat5/feladat5/CMyString.cpp +++ b/feladat5/feladat5/CMyString.cpp @@ -1 +1,110 @@ -// Tóth Dániel Mátyás | IFPQYY | v1 \ No newline at end of file +// Tóth Dániel Mátyás | IFPQYY | v1 +#include "CMyString.h" +#include "CMyStringException.h" + +CMyString::CMyString() { + m_nDataLength = 0; + m_nAllocLength = 1; + m_pchData = new char[m_nAllocLength]; + m_pchData[0] = '\0'; +} +CMyString::CMyString(const char* psz) { + m_nDataLength = 0; + if (psz == nullptr) + { + m_nAllocLength = 1; + } + else + { + while (psz[m_nDataLength]) + { + m_nDataLength++; + } + m_nAllocLength = m_nDataLength + 1; + } + m_pchData = new char[m_nAllocLength]; + int i = 0; + while (i < m_nAllocLength) + { + m_pchData[i] = psz[i]; + i++; + } + m_pchData[i] = '\0'; +} +CMyString::CMyString(char ch, size_t repeat = 1) { + m_nDataLength = repeat; + m_nAllocLength = repeat + 1; + m_pchData = new char[m_nAllocLength]; + int i = 0; + while (i < repeat) + { + m_pchData[i] = ch; + i++; + } + m_pchData[i] = '\0'; +} +CMyString::CMyString(const CMyString& str) { + if (str.empty()) + { + m_nDataLength = 0; + } + else + { + m_nDataLength = str.size(); + } + m_nAllocLength = m_nDataLength + 1; + m_pchData = new char[m_nAllocLength]; + int i = 0; + const char* cont = str.c_str(); + while (cont[i]) + { + m_pchData[i] = cont[i]; + i++; + } + m_pchData[i] = '\0'; +} +CMyString::~CMyString() { + delete m_pchData; +} +size_t CMyString::size() const { + +} +size_t CMyString::capacity() const { + +} +const char* CMyString::c_str() const { + +} +void CMyString::clear() { + +} +char CMyString::getat(size_t index) const { + +} +void CMyString::setat(size_t index, char ch) { + +} +void CMyString::reserve(size_t newcapacity) { + +} +void CMyString::erase(size_t pos, size_t count) { + +} +bool CMyString::empty() const { + return m_nDataLength == 0; +} +void CMyString::display() const { + +} +void CMyString::shrink_to_fill() { + +} +void CMyString::reverse() { + +} +void CMyString::append(const char* psz, unsigned offset = 0, unsigned count = -0) { + +} +CMyString& CMyString::operator=(const CMyString& str) { + +} \ No newline at end of file diff --git a/feladat5/feladat5/CMyStringException.cpp b/feladat5/feladat5/CMyStringException.cpp index 0da902b..90cf5db 100644 --- a/feladat5/feladat5/CMyStringException.cpp +++ b/feladat5/feladat5/CMyStringException.cpp @@ -1,110 +1,2 @@ // Tóth Dániel Mátyás | IFPQYY | v1 -#include "CMyString.h" #include "CMyStringException.h" - -CMyString::CMyString(){ - m_nDataLength = 0; - m_nAllocLength = 1; - m_pchData = new char[m_nAllocLength]; - m_pchData[0] = '\0'; -} -CMyString::CMyString(const char* psz){ - m_nDataLength = 0; - if (psz == nullptr) - { - m_nAllocLength = 1; - } - else - { - while (psz[m_nDataLength]) - { - m_nDataLength++; - } - m_nAllocLength = m_nDataLength + 1; - } - m_pchData = new char[m_nAllocLength]; - int i = 0; - while (i < m_nAllocLength) - { - m_pchData[i] = psz[i]; - i++; - } - m_pchData[i] = '\0'; -} -CMyString::CMyString(char ch, size_t repeat = 1){ - m_nDataLength = repeat; - m_nAllocLength = repeat + 1; - m_pchData = new char[m_nAllocLength]; - int i = 0; - while (i < repeat) - { - m_pchData[i] = ch; - i++; - } - m_pchData[i] = '\0'; -} -CMyString::CMyString(const CMyString& str){ - if (str.empty()) - { - m_nDataLength = 0; - } - else - { - m_nDataLength = str.size(); - } - m_nAllocLength = m_nDataLength + 1; - m_pchData = new char[m_nAllocLength]; - int i = 0; - const char* cont = str.c_str(); - while (cont[i]) - { - m_pchData[i] = cont[i]; - i++; - } - m_pchData[i] = '\0'; -} -CMyString::~CMyString(){ - delete m_pchData; -} -size_t CMyString::size() const { - -} -size_t CMyString::capacity() const { - -} -const char* CMyString:: c_str() const { - -} -void CMyString::clear() { - -} -char CMyString::getat(size_t index) const { - -} -void CMyString::setat(size_t index, char ch) { - -} -void CMyString::reserve(size_t newcapacity) { - -} -void CMyString::erase(size_t pos, size_t count) { - -} -bool CMyString::empty() const { - return m_nDataLength == 0; -} -void CMyString::display() const { - -} -void CMyString::shrink_to_fill() { - -} -void CMyString::reverse() { - -} -void CMyString::append(const char* psz, unsigned offset = 0, unsigned count = -0) { - -} -CMyString& CMyString::operator=(const CMyString& str) { - -} \ No newline at end of file