본문 바로가기
반응형

SWE/C++ OOP43

C++ 랜덤 문자로 array 채우기 | std::generate C언어에서 랜덤 문자로 array 채우는 방법 for문 사용해서 일일이 채워준다. char buf[100] = {0, }; for (int i=0; i 2022. 10. 28.
c++ type casting 부모 형변환 데이터 손실이 있을까? c++의 cast operator를 사용하면 형변환이 가능하다. static_cast operator를 이용해서 업캐스팅하고 다시 다운캐스팅하면 기존의 값을 유지할까? *업캐스팅: 자식 클래스에서 부모클래스로 형변환 *다운캐스팅: 부모클래스에서 자식클래스로 형변환 테스트 코드 #include using namespace std; class Parent { }; class Child : public Parent { public: int value_c = 0; }; int main() { // child instance 생성 Child* child = new Child(); // child의 value_c 값 지정 child->value_c = 3; // Upcasting : child에서 parent로 형.. 2022. 10. 6.
google c++ style guide | 구글 C++ 스타일 가이드 C++ Version Currently, code should target C++17 Header file Use header file. i.e. Every .cc file should have an associated .h file. Exceptions: such as unit tests and small .cc files containing just a mian() function. Use of header files is much better for the readibility, size and performance of the code. (1) Self-contained Headers Header file should be self-contained and end in .h. Non-header .. 2022. 4. 13.
객체와 컴포넌트의 차이 | CBD 컴포넌트 기반 개발 객체와 컴포넌트의 차이 : https://mckdh.tistory.com/entry/%EA%B0%9D%EC%B2%B4%EC%A7%80%ED%96%A5%EC%9D%98-%ED%83%84%EC%83%9D-%EA%B0%9D%EC%B2%B4%EC%99%80-%EC%BB%B4%ED%8F%AC%EB%84%8C%ED%8A%B8-%EC%95%84%ED%82%A4%EC%B2%B5%EC%B2%98%EC%99%80-%EC%95%84%ED%82%A4%ED%85%8D%ED%8A%B8 객체지향의 탄생- 객체와 컴포넌트, 아키첵처와 아키텍트 객체와 컴포넌트 객체란 실체로 존재하는 대상/개념이며 고유명사이다. 객체는 세상에 유일하게 존재하는 모든 것들~이라고 정의했다. 나는 객체만 알면 되는 줄 알았다. 그런데 컴포넌트란 용 mck.. 2022. 4. 12.
반응형