본문 바로가기

분류 전체보기140

OOP (Object-Oriented-Project) OOP 단계별 프로젝트 01단계 #include #include "banking.h"using namespace std;typedef struct information { int ID; char name[100]; int money;}psinfo;psinfo customers[1000];void printmenu(){ cout > choice; if (choice == 1) { open_account(); } if (choice == 2) { deposit(); } if (choice == 3) { withdraw(); } if (choice == 4) { printinfo(); } if (choice == 5) { return 0; } else { cout > ID; customers[ID].. 2024. 8. 7.
문제 04-3 [C++ 기반의 데이터 입출력] 문제 1#include using namespace std;class Point{private: int xpos; int ypos;public: Point(int x, int y) :xpos(x),ypos(y) { } void ShowPointInfo() const { cout 2024.08.05 - [C++] - 문제 04-2 [다양한 클래스의 정의] 문제 04-2 [다양한 클래스의 정의]#include using namespace std;class Point{private: int xpos; int ypos;public: void Init(int x, int y) { xpos = x; ypos = y; } void ShowPointInfo() const { cout  const 선언 잊지말기캡.. 2024. 8. 6.
문제 04-2 [다양한 클래스의 정의] #include using namespace std;class Point{private: int xpos; int ypos;public: void Init(int x, int y) { xpos = x; ypos = y; } void ShowPointInfo() const { cout  const 선언 잊지말기캡슐화 신경쓰기 다른버전#include using namespace std;class Point{private: int xpos; int ypos;public: void Init(int x, int y) { xpos = x; ypos = y; } void ShowPointInfo() const { cout 2024. 8. 5.
문제 04-1 [정보은닉과 const] 2024.08.05 - [C++] - OOP (Object-Oriented-Programming) OOP (Object-Oriented-Programming)1단계 #include using namespace std;class Fruitseller{private: int APPLE_PRICE; int numOfApples; int myMoney;public: void InitMembers(int price, int num, int money) { APPLE_PRICE = price; numOfApples = num; myMoney = money; } int SaleApples(int money) {kwone.tistory.com코드 참조 FruitSaleSim1.cppclass Fruitseller{pr.. 2024. 8. 5.
Class 활용 예제 1. (객체 생성 및 초기화)#include using namespace std;class Fruitseller{private: int APPLE_PRICE; int numOfApples; int myMoney;public: void InitMembers(int price, int num, int money) { APPLE_PRICE = price; numOfApples = num; myMoney = money; } int SaleApples(int money) { int num = money / APPLE_PRICE; numOfApples -= num; myMoney += money; return num; } void ShowSalesResult() { cout 2. (생성자 활용)#in.. 2024. 8. 5.
문제 03-2 [클래스의 정의] 문제 1#pragma once#ifndef __CALCULATOR_H__#define __CALCULATOR_H__#include class Calculator{private: int Add_count; int Mul_count; int Div_count; int Min_count;public: double Add(double num1, double num2); double Div(double num1, double num2); double Min(double num1, double num2); double Mul(double num1, double num2); void Init(); void ShowOpCount();};#endifcalculator.h 헤더파일#include #include "calc.. 2024. 8. 2.