c++ 친구 함수와 클래스 friend
c++ 친구 함수와 클래스 friend
2020.10.30#include using namespace std; class A { private: int m_value = 1; }; void doSomething(A& a) { cout
c++ 문자열을 정수로 변환하기(stoi)
c++ 문자열을 정수로 변환하기(stoi)
2020.10.30#include #include using namespace std; int main() { string str1 = "10"; string str2 = "2.456"; string str3 = "456 문자열"; int num1 = stoi(str1); int num2 = stoi(str2); int num3 = stoi(str3); cout
c++ 문자열 일부 교체하기(replace)
c++ 문자열 일부 교체하기(replace)
2020.10.30#include #include using namespace std; int main() { string sentence = "i like coding"; string find_str = "coding"; string replace_str = "history"; sentence.replace(sentence.find(find_str), find_str.length(), replace_str); cout
c++ 문자열에서 특정 문자만 제거하기
c++ 문자열에서 특정 문자만 제거하기
2020.10.30#include #include using namespace std; int main() { string sentence = "i like coding"; sentence.erase(remove(sentence.begin(), sentence.end(), ' '), sentence.end()); cout
c++ 문자열 이동하기(move)
c++ 문자열 이동하기(move)
2020.10.30#include #include #include using namespace std; int main() { string str1 = "i like coding"; string str2 = move(str1); cout
c++ 문자열 일부 지우기(erase)
c++ 문자열 일부 지우기(erase)
2020.10.29#include #include using namespace std; int main() { string sentence = "i hate coding"; sentence.erase(0, 7); cout
c++ static member function (정적 멤버 함수)
c++ static member function (정적 멤버 함수)
2020.10.29#include using namespace std; class Something private: static int s_value; public: static int getValue() { return s_value; } int temp() { return this->s_value; } }; int main() { Something s1; Something s2; cout
c++ static member 변수
c++ static member 변수
2020.10.29class Something { public: static int s_value; }; int Something::s_value = 1; int main() { cout
c++ 문자열 중간에 삽입하기
c++ 문자열 중간에 삽입하기
2020.10.28#include #include using namespace std; int main() { string sentence = "i coding"; sentence.insert(2, "hate "); cout
c++ 문자열 길이 구하기
c++ 문자열 길이 구하기
2020.10.28#include #include using namespace std; int main() { string fist_name = "ha"; string last_name = "jong yun"; cout
c++ 문자열 조회하기(find)
c++ 문자열 조회하기(find)
2020.10.28#include #include using namespace std; int main() { string alpa = "abcdefghijklmnopqrst"; int rtn = alpa.find("jk"); if (rtn > 0) cout
c++ class 와 const
c++ class 와 const
2020.10.28#include #include using namespace std; class Something { public: int m_value = 0; Something(const Something& st_in) { m_value = st_in.m_value; cout