본문 바로가기

언어/C++

c++와 java의 차이점 1. c: char 1byte -아스키코드 java : char 2byte - 유니코드 .utf-8 인코딩 방식 권장 2. c: unsigned 형식 있음 java : unsigned는 char만 있고 , 따로 unsigned는 없다 long 으로 쓴다 . 3. c: 생성자 소멸자 개념이있음 java: 생성자는 있지만 소멸자 개념은 없음 4 c: 컴파일언어 java: 컴파일언어 + 인터프리터 언어 https://ljhh.tistory.com/entry/%EC%BB%B4%ED%8C%8C%EC%9D%BC%EB%9F%AC%EC%99%80-%EC%9D%B8%ED%84%B0%ED%94%84%EB%A6%AC%ED%84%B0-%ED%8A%B9%EC%A7%95-%EB%B0%8F-%EC%9E%A5%EB%8B%A8%EC%.. 더보기
가상함수 로 단위 변환기 ! #include #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ class Converter{ protected: double ratio; virtual double convert(double src)=0; virtual string getSourceString()=0; virtual string getDestString()=0; public: Converter(double ratio){ this->ratio=ratio; } void run(){ double src; cout 더보기
프린터 상속 잉크젯/ 레이저 프린터로 프린터 하기 ! #include #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ class printer { string model; string manufacturer; int printedCount; int availableCount; public: printer(string m, string ma, int a){ model=m; manufacturer=ma; availableCount=a; } string getModel(){ return model; } string getManu(){ return manufacturer; } in.. 더보기
박스 상속 스택 박스에 공넣고 빼기! #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ class BaseArray{ int capacity; int *mem; protected: BaseArray(int capacity=100){ this->capacity=capacity; mem= new int[capacity]; } ~BaseArray(){ delete [] mem; } void put(int index, int val){ mem[index]=val; } int get(int index){ return mem[index]; } int getCapacity.. 더보기
박스 상속 큐박스에 공 넣고 빼기 ! #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ class BaseArray{ int capacity; int *mem; protected: BaseArray(int capacity=100){ this->capacity=capacity; mem= new int[capacity]; } ~BaseArray(){ delete [] mem; } void put(int index, int val){ mem[index]=val; } int get(int index){ return mem[index]; } int getCapacity.. 더보기
점 상속 받은 불꽃놀이 ! #include #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ class Point { int x; int y; public: Point(int x,int y){ this->x=x; this->y=y; } int getX(){ return x; } int getY(){ return y; } protected: void move(int x, int y){ this->x=x; this->y=y; } }; class ColorPoint : public Point{ string name; public: ColorPoint(in.. 더보기
원가게 상속 피자 메뉴 고르기 ! #include #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ class Circle{ int radius; public: Circle(int radius=0) { this->radius=radius; } int getRadius(){ return radius; } void setRadius(int radius){ this->radius=radius; } double getArea(){ return 3.14*radius*radius; } }; class NamedCircle : public Circle{ string n.. 더보기
원 가게 상속 와플 만들기 ! #include #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ class Circle{ int radius; public: Circle(int radius=0) { this->radius=radius; } int getRadius(){ return radius; } void setRadius(int radius){ this->radius=radius; } double getArea(){ return 3.14*radius*radius; } }; class NamedCircle : protected Circle{ strin.. 더보기