Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. #ifndef location_h
  2. #define location_h
  3.  
  4. class location
  5. {
  6. public:
  7. setpoint(int,int,int);
  8. getpoint(int,int,int);
  9.  
  10.  
  11.  
  12. private:
  13. int x,y,z;
  14. };
  15. #endif
  16.  
  17. #include<iostream>
  18. using std::cout;
  19. using std::cin;
  20. using std::endl;
  21.  
  22. #include"location.h"
  23.  
  24. location::getpoint(int a,int b,int c)
  25. {
  26. x=a;
  27. y=b;
  28. z=c;
  29.  
  30. cout<<"give point x"<<x<<endl;
  31. cout<<"give point y"<<y<<endl;
  32. }
  33.  
  34. #ifndef creature_h
  35. #define creature_h
  36.  
  37. #include"location.h"
  38. #include<string>
  39. //using std::string;
  40. using namespace std;
  41. class creature
  42. {
  43. public:
  44. creature();
  45. moveto(location l);
  46. getname(string n);
  47. printlocation(string ,location );
  48.  
  49. private:
  50. location lo;
  51. string name;
  52.  
  53. };
  54. #endif
  55.  
  56. #include<iostream>
  57. using std::cout;
  58. using std::endl;
  59. using std::cin;
  60. using namespace std;
  61.  
  62.  
  63. #include<string>
  64. #include"creature.h"
  65. #include"location.h"
  66.  
  67. creature::creature()
  68. {
  69. lo;
  70. name;
  71. }
  72. creature::getname(string n)
  73. {
  74. name=n;
  75. cout<<"enter name";
  76. cin>>n;;
  77. }
  78. creature::printlocation()
  79. :name(n),lo(l)
  80. {
  81. name=n;
  82. lo=l;
  83. cout<<lo.setpoint(int,int,int);
  84.  
  85. }
  86.  
  87. #ifndef creature_h
  88. #define creature_h
  89.  
  90. #include"location.h"
  91. #include<string>
  92. //using std::string;
  93. using namespace std;
  94. class creature
  95. {
  96. public:
  97. creature();
  98. void moveto(location l);
  99. void getname(string );
  100. void printlocation(string ,location );
  101.  
  102. private:
  103.  
  104. location lo;
  105. string name;
  106.  
  107. };
  108. #endif
  109.  
  110. #include<iostream>
  111. using std::cout;
  112. using std::endl;
  113. using std::cin;
  114. using namespace std;
  115.  
  116.  
  117. #include<string>
  118. #include"creature.h"
  119. #include"location.h"
  120.  
  121. /*creature::creature()
  122. {
  123. lo;
  124. name;
  125. }*/
  126. void creature::getname(string n)
  127. {
  128. name=n;
  129. cout<<"enter name";
  130. cin>>n;
  131. }
  132. void creature::printlocation()
  133. :name(n),lo(l)
  134. {
  135. name=n;
  136. lo=l;
  137. cout<<l.getpoint(int,int,int);
  138.  
  139. }
  140.  
  141. #include<iostream>
  142. using std::cout;
  143. using std::cin;
  144. using std::endl;
  145. using namespace std;
  146.  
  147. #include"location.h"
  148. #include"creature.h"
  149. #include<string>
  150.  
  151. main()
  152. {
  153. string n;
  154. int x,y,z;
  155. location l;
  156. l.getpoint(x,y,z);
  157.  
  158. creature c;
  159. c.getname(n);
  160. c.printlocation(n,l);
  161. return 0;
  162.  
  163. }
  164.  
  165. void printlocation( std::string ,location );
  166.  
  167. void creature();
  168. void moveto(location l);
  169. void getname(string n);
  170.  
  171. std::string s;
  172. location l;
  173. //... give some value to s and l ...
  174. printlocation( s, l);
  175.  
  176. class location
  177. {
  178. public:
  179. setpoint(int,int,int);
  180. getpoint(int,int,int);
  181. //...
  182.  
  183. class creature
  184. {
  185. public:
  186. //...
  187. moveto(location l);
  188. getname(string n);
  189. printlocation(string ,location );
  190. //...
  191.  
  192. void setpoint(int,int,int);
  193.  
  194. location::getpoint(int a,int b,int c)
  195. {
  196. x=a;
  197. y=b;
  198. z=c;
  199.  
  200. cout<<"give point x"<<x<<endl;
  201. cout<<"give point y"<<y<<endl;
  202. }
  203.  
  204. void location::setpoint(int a,int b,int c)
  205. {
  206. x=a;
  207. y=b;
  208. z=c;
  209.  
  210. cout<<"give point x"<<x<<endl;
  211. cout<<"give point y"<<y<<endl;
  212. }
  213.  
  214. // NOTE the parameter defintions!!
  215. void creature::printlocation(string n,location l) {
  216. name=n;
  217. lo=l;
  218. cout<<lo.setpoint(1,2,3);
  219. }
  220.  
  221. void creature::printlocation() : name(n),lo(l)
  222. // ^^^^^^^^^^^^^^^ This is wrong!!!
  223.  
  224. class creature {
  225. public:
  226. creature() (string n,location l) : name(n),lo(l) {}
  227. // ...
  228. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement