第六週項目一:誤りを改める

772 ワード

/*   

*                

* Copyright (c)2013,               

* 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;

}



/*

     

*/



#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()

{  const C c(5);

  cout<<c.getX();

  return 0;

}