2014年4月4日金曜日

開発環境

C++実践プログラミング (スティーブ オウアルライン (著)、Steve Oualline (原著)、Steve Oualline(原著)、望月 康司(翻訳)、クイープ(翻訳) 、オライリー・ジャパン)のⅣ部(高度なプログラミング概念)の16章(ファイル入出力)、16.13(プログラミング実習)、実習 16-6.を解いてみる。

その他参考書籍

実習 16-6.

コード(BBEdit, Emacs)

sample306_6.cpp

#include <iostream>
#include <string>
#include <iomanip>

class mailing {
private:
  std::string name;
  std::string address;
  std::string other;
public:
  explicit mailing(const std::string i_name, const std::string i_address,
                   const std::string i_other) {
    name = i_name;
    address = i_address;
    other = i_other;
  }
  // mailing(const mailing& old_class)
  // ~mailing()
  // operator = (const mailing& old_class)
  void print();
};

inline void mailing::print()
{
  int w = 10;
  std::cout << std::setw(w) << "name: " << name << '\n' << std::setw(w) <<
    "address: " << address << '\n' << std::setw(w) << "other: " << other <<
    '\n';
}

int main(int argc, char *argv[])
{
  mailing m("kamimura", "Japan", "Kamimura's blog");
  m.print();
  return (0);
}

Makefile

#
# FSFのg++コンパイラ用のMakefile
#
CC=g++
CFLAGS=-g -Wall
all: sample306_6

sample306_6: sample306_6.cpp
 ${CC} ${CFLAGS} -o sample306_6 sample306_6.cpp

clean:
 rm sample306_6

入出力結果(Terminal)

$ make && ./sample306_6
g++ -g -Wall -o sample306_6 sample306_6.cpp
    name: kamimura
 address: Japan
   other: Kamimura's blog
$

0 コメント:

コメントを投稿