일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 빅 데이타
- 김양재 목사님
- 우리들교회
- 딥러닝
- c++
- Machine Learning
- 인공지능
- WebGL
- R
- data science
- 몽고디비
- Artificial Intelligence
- 주일설교
- Statistics
- 빅데이터
- 김양재
- 김양재 목사
- probability
- Deep learning
- node.js
- openCV
- nodeJS
- 빅데이타
- 빅 데이터
- 통계
- Big Data
- 확률
- MongoDB
- No SQL
- 데이터 과학
Archives
- Today
- Total
Scientific Computing & Data Science
[C/C++] Example / Class Constructor 본문
"student.h"
//
// student.h
// Test-001
//
// Created by gchoi on 2014. 5. 6..
// Copyright (c) 2014년 gchoi. All rights reserved.
//
#ifndef Test_001_student_h
#define Test_001_student_h
#include <iostream>
#include <string>
using namespace std;
class Student {
private:
int no;
string name;
int eng;
int math;
public:
Student();
Student(int no, string name, int eng, int math);
void setNo(int no);
void setName(string name);
void setEng(int eng);
void setMath(int math);
int getNo();
string getName();
int getEng();
int getMath();
void showData();
};
#endif
"student.cpp"
//
// student.cpp
// Test-001
//
// Created by gchoi on 2014. 5. 6..
// Copyright (c) 2014년 gchoi. All rights reserved.
//
#include "student.h"
#include <string>
using namespace std;
Student::Student() {
this->no = 0;
this->name = "";
this->eng = 0;
this->math = 0;
}
Student::Student(int no, string name, int eng, int math) {
this->no = no;
this->name = name;
this->eng = eng;
this->math = math;
}
void Student::setNo(int no) {
this->no = no;
}
void Student::setName(string name) {
this->name = name;
}
void Student::setEng(int eng) {
this->eng = eng;
}
void Student::setMath(int math) {
this->math = math;
}
int Student::getNo() {
return this->no;
}
string Student::getName() {
return this->name;
}
int Student::getEng() {
return this->eng;
}
int Student::getMath() {
return this->math;
}
void Student::showData() {
cout << no << endl;
cout << name << endl;
cout << eng << endl;
cout << math << endl;
}
"main.cpp"
//
// main.cpp
//
#include <iostream>
#include <string>
#include "student.h"
using namespace std;
int main( int argc , const char * argv [])
{
Student *gchoi = new Student(15, "Geol Choi", 99, 100);
//gchoi->setNo(15);
//gchoi->setName("Geol Choi");
//gchoi->setEng(99);
//gchoi->setMath(100);
cout << gchoi->getNo() << endl;
cout << gchoi->getName() << endl;
cout << gchoi->getEng() << endl;
cout << gchoi->getMath() << endl;
delete gchoi;
return 0 ;
}
'Programming > C&C++' 카테고리의 다른 글
[C/C++] Example / Ordering - Descending Algorithms (0) | 2014.06.12 |
---|---|
[C/C++] Example / Derived Class (0) | 2014.06.12 |
[C/C++] Example / Class (0) | 2014.06.12 |
[C/C++] Example / Pointer of Structure (0) | 2014.06.12 |
[C/C++] Example / Structure (0) | 2014.06.12 |
Comments