일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- No SQL
- node.js
- 빅 데이타
- R
- 빅데이타
- 확률
- 통계
- 주일설교
- 김양재
- 몽고디비
- openCV
- Deep learning
- MongoDB
- 김양재 목사님
- Artificial Intelligence
- 김양재 목사
- 빅데이터
- Machine Learning
- 인공지능
- WebGL
- data science
- probability
- c++
- Statistics
- 빅 데이터
- 데이터 과학
- nodeJS
- 우리들교회
- 딥러닝
- Big Data
Archives
- Today
- Total
Scientific Computing & Data Science
[C/C++] Example / Derived Class 본문
//
// main.cpp
// Test-002
//
// Created by gchoi on 2014. 5. 6..
// Copyright (c) 2014년 gchoi. All rights reserved.
//
#include <iostream>
#include <string>
using namespace std;
//////////////////////////////////////////////////
class Student {
private:
int no;
string name;
public:
Student();
Student(int no, string name);
~Student();
protected:
void setNo(int no);
void setName(string name);
int getNo();
string getName();
void showData();
};
Student::Student() {
this->no = 0;
this->name = "";
}
Student::Student(int no, string name) {
this->no = no;
this->name = name;
}
Student::~Student() {
}
void Student::setNo(int no) {
this->no = no;
}
void Student::setName(string name) {
this->name = name;
}
int Student::getNo() {
return this->no;
}
string Student::getName() {
return this->name;
}
void Student::showData() {
cout << "No : " << no << endl;
cout << "Name : " << name << endl;
}
//////////////////////////////////////////////////
class Mathtest : public Student {
private:
int math;
public:
Mathtest();
Mathtest(int no, string name, int math);
void setNo(int no);
void setName(string name);
void setMath(int math);
int getNo();
string getName();
int getMath();
void showAllData();
};
Mathtest::Mathtest() {
this->math = 0;
}
Mathtest::Mathtest(int no, string name, int math) : Student(no, name) {
this->math = math;
}
void Mathtest::setNo(int no) {
Student::setNo(no);
}
void Mathtest::setName(string name) {
Student::setName(name);
}
int Mathtest::getNo() {
return Student::getNo();
}
string Mathtest::getName() {
return Student::getName();
}
void Mathtest::setMath(int math) {
this->math = math;
}
int Mathtest::getMath() {
return this->math;
}
void Mathtest::showAllData() {
Student::showData();
cout << "Math : " << math << endl;
}
//////////////////////////////////////////////////
int main(int argc, const char * argv[])
{
Mathtest *gchoi = new Mathtest(15, "Geol Choi", 100);
gchoi->setName("gchoi");
gchoi->setNo(22);
gchoi->showAllData();
cout << gchoi->getNo() << endl;
return 0;
}
'Programming > C&C++' 카테고리의 다른 글
[C/C++] Example / Writing a File (0) | 2014.06.12 |
---|---|
[C/C++] Example / Ordering - Descending Algorithms (0) | 2014.06.12 |
[C/C++] Example / Class Constructor (0) | 2014.06.12 |
[C/C++] Example / Class (0) | 2014.06.12 |
[C/C++] Example / Pointer of Structure (0) | 2014.06.12 |
Comments