第6週の搭乗任務(変更1)

957 ワード

方法1:
/*  
*               
* Copyright (c)2012,              
* All rightsreserved.  
*     : object.cpp  
*   :     
*     : 2013  4   5     
*    : v1.0  
*     :   
*     : 
*     :
*/    
#include<iostream>
#include<stdlib.h>
using namespace std;
class C
{private:
  int x;
 public:
  C(int x){this->x = x;}
  int getX(){return x;}
};
int main()
{  C c(5);
  cout<<c.getX();
  return 0;
}


方法2:
#include<iostream>
#include<stdlib.h>
using namespace std;
class C
{private:
  int x;
 public:
  C(int x){this->x = x;}
  int getX()const{return x;}
};
int main()
{  C c(5);
  cout<<c.getX();
  return 0;
}


実行結果: