第六章オブジェクト向けプログラム設計


/*
// 4  
#include <iostream>
using namespace std;
class Human
{
public:
	void GetStature();
	void getWeight();
private:
	int stature;
	int weigth;
};
int main()
{
    return 0;
}

*/


/*
//6  
#include <iostream>
using namespace std;
class human
{
public:
	void getStartue(){cout<<startue; }
	void setStartue(int x){startue = x;}
	void getWeight();
	void setWeight(int y);
private:
	int startue;
	int weight;
};
void human::getWeight()
{
    cout<<weight;
};
void human::setWeight(int y)
{
    weight = y;
};
int main()
{
	human man;
	man.setStartue(18);
	man.setWeight(112);
	cout<<" :";
	man.getStartue();
	cout<<",  :";
	man.getWeight();
	cout<<endl;

    return 0;
}
*/


//8 
/*#include <iostream>
using namespace std;
class Human
{
public:
	void setWeigth(int w)
	{
		if(w > 0 && w < 100){
		    weigth = w;
		}else{
		    cout<<" 1 100"<<endl;
		}
	}
	int getWeigth(){ return weigth;}
private:
	int weigth;
};
int main()
{
	Human human;
	human.setWeigth(222);
	cout<<" :"<<human.getWeigth()<<endl;
	
	Human tow;
	tow.setWeigth(33);
	cout<<" :"<<tow.getWeigth()<<endl;
    return 0;
}
*/

/*
//10  
#include <iostream>
using namespace std;
class Human
{
public:
	inline void func(int);
	int get(){return x;}
private:
	int x;
};
void Human::func(int s){ x=s;};
int main()
{
	Human human;
	human.func(22);
	cout<<human.get()<<endl;

    return 0;
}
*/

#include <iostream>
using namespace std;
class Human
{
public:
	void func(int x, int s){ i=x, y=s;};
	void print(){
		cout<<"i:"<<i<<", y:"<<y<<endl;
		cout<<" X :"<<i*y<<endl;
	};
private:
	int i;
	int y;
};

/*#include "11_human.h";
int main()
{
	Human human;
	human.func(22,33);
	human.print();
    return 0;
}*/


/*
//12 const  
//const 
#include <iostream>
using namespace std;
class Human
{
public:
	void func(int x, int s){ i=x, y=s;};
	void print()const{
		cout<<"i:"<<i<<", y:"<<y<<endl;
		cout<<" X :"<<i*y<<endl;
	};
private:
	int i;
	int y;
};
int main()
{
   Human human;
   human.func(22,22);
   human.print();
   return 0;
}
*/


/*
// 13 
#include <iostream>
using namespace std;
class Rectangel
{
public:
	Rectangel(){};
	Rectangel(int l, int w){ lenght=l, width=w;};
	int area(){ return lenght * width;}
private:
	int lenght;
	int width;
};
int main()
{
	Rectangel rectangel(2,3);
	cout<<rectangel.area()<<endl;

	Rectangel xx;
	cout<<xx.area()<<endl;

    return 0;

}
*/

//15  
#include <iostream>
using namespace std;
class A
{
public:
	A(){cout<<" "<<endl;}
	~A(){cout<<" "<<endl;}
};
int main()
{
   A a;


   // 
   cout<<" "<<endl;
   A b[2];

   return 0;
}