2010-08-01から1ヶ月間の記事一覧

『Cプログラマのための C++入門』

『Cプログラマのための C++入門』 柴田望洋『Cプログラマのための C++入門』を勉強してまいります。 1. C++ に慣れよう 1-1-1 コメント 1-1-2 定数 1-2-1 関数プロトタイプ 1-2-2 可変個引数 1-2-3 デフォルト引数 1-2-4 インライン引数 1-3-1 Cリンケージと…

メンバへのポインタ

Cプログラマのための C++入門 > 2.クラスの概念 > メンバへのポインタ C++ #include <stdio.h> #include "Student.h"int main(int argc, char* argv[]) { Student Shibata("柴田望洋", 180, 80); Student Masuyan("増田真二", 170, 60); Shibata.Print(); Masuyan.Pri</stdio.h>…

コンストラクタ

Cプログラマのための C++入門 > 2.クラスの概念 > コンストラクタ C++ #include <stdio.h> #include "Student.h"void PrintStudent(Student x) { printf("%s\n", x.Name()); printf(" 英語 = %d\n", x.English()); printf(" 数学 = %d\n", x.Mathematics()); printf("</stdio.h>…

this ポインタ

Cプログラマのための C++入門 > 2.クラスの概念 > this ポインタ C++ #include <stdio.h>struct student { public: char name[20]; int eng; int math; private: int ave; public: void calc_ave(); int average(); };void student::calc_ave() { this->ave = (this-></stdio.h>…

メンバ関数

Cプログラマのための C++入門 > 2.クラスの概念 > メンバ関数 C++ #include <stdio.h>struct student { public: char name[20]; int eng; int math; private: int ave; public: void calc_ave(); int average(); };void student::calc_ave() { ave = (eng + math) / 2</stdio.h>…

構造体とメンバの透過性

Cプログラマのための C++入門 > 2.クラスの概念 > 構造体とメンバの透過性 C++ #include <stdio.h>struct student { char name[20]; int eng; int math; int ave; };void calc_ave(student* x) { x->ave = (x->eng + x->math) / 2; }int average(student* x) { return</stdio.h>…

関数の多重定義

Cプログラマのための C++入門 > 1. C++ に慣れよう > 関数の多重定義 C++ #include <stdio.h>int abs(int x) { return (x < 0 ? -x : x); } long abs(long x) { return (x < 0L ? -x : x); } double abs(double x) { return (x < 0.0 ? -x : x); }int main(int argc, </stdio.h>…