• R/O
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

練習用です。いろんなものがごちゃまぜです。


Commit MetaInfo

Revision43 (tree)
Time2015-09-21 09:24:39
Authorbellyoshi

Log Message

(empty log message)

Change Summary

Incremental Difference

--- TeachYourSelf/myclass.cpp (revision 42)
+++ TeachYourSelf/myclass.cpp (revision 43)
@@ -2,21 +2,25 @@
22 using namespace std;
33
44 class myclass {
5- int i, j;
5+ int a, b;
66 public:
77 myclass(int a, int b);
8+ int add(){return a + b;}
89 void show();
910 };
1011 myclass::myclass(int a, int b)
1112 {
1213 cout << "myclass(int a,int b)コンストラクタ呼び出し\n";
13- i = a;
14- j = b;
14+ this->a = a;
15+ this->b = b;
1516 }
1617
1718 void myclass::show()
1819 {
19- cout << i << ' ' << j << "\n";
20+ cout << "myclass::show()の呼び出し\n";
21+ cout << this->a << ' ' << this->b << "\n";
22+ int t = this->add();
23+ cout << t << "\n";
2024 }
2125
2226 int main()
--- TeachYourSelf/samparray6.cpp (nonexistent)
+++ TeachYourSelf/samparray6.cpp (revision 43)
@@ -0,0 +1,32 @@
1+#include <iostream>
2+using namespace std;
3+
4+class samp{
5+ int a,b;
6+public:
7+ samp(int n,int m){a = n;b =m;}
8+ int get_a(){return a;}
9+ int get_b(){return b;}
10+};
11+
12+int main()
13+{
14+ samp ob[4][2] = {{samp(1,2),samp(3,4)},
15+ {samp(5,6),samp(7,8)},
16+ {samp(9,10),samp(11,12)},
17+ {samp(13,14),samp(15,16)}};
18+
19+ samp *p = &ob[3][1];
20+ for(int i = 0; i < 4; i++){
21+ for(int j = 0; j < 2; j++){
22+ cout << p->get_a() << ',';
23+ cout << p->get_b() << ' ';
24+ p--;
25+ }
26+ cout << "\n";
27+ }
28+
29+ cout << "\n";
30+
31+ return 0;
32+}
\ No newline at end of file
--- TeachYourSelf/newsamparray.cpp (nonexistent)
+++ TeachYourSelf/newsamparray.cpp (revision 43)
@@ -0,0 +1,19 @@
1+#include <iostream>
2+using namespace std;
3+
4+class samp{
5+ int i,j;
6+public:
7+ samp(){cout << "コンストラクタ\n";}
8+ ~samp(){cout << "デストラクタ\n";}
9+ void set_ij(int a, int b){i = a;j = b;}
10+ int get_product(){return i*j;}
11+};
12+
13+int main()
14+{
15+ samp *p = new samp[10];
16+ cout << "hello\n";
17+ delete [] p;
18+ return 0;
19+}
\ No newline at end of file
--- TeachYourSelf/newsamp.cpp (nonexistent)
+++ TeachYourSelf/newsamp.cpp (revision 43)
@@ -0,0 +1,24 @@
1+#include <iostream>
2+using namespace std;
3+
4+class samp{
5+ int i,j;
6+public:
7+ void set_ij(int a, int b){i = a;j = b;}
8+ int get_product(){return i*j;}
9+};
10+
11+int main()
12+{
13+ samp *p;
14+ p = new samp;
15+ if(!p){
16+ cout << "メモリ割り当てエラー\n";
17+ return 1;
18+ }
19+
20+ p->set_ij(4,5);
21+ cout << "積は:" << p->get_product() << "\n";
22+ delete p;
23+ return 0;
24+}
\ No newline at end of file
--- TeachYourSelf/new.cpp (nonexistent)
+++ TeachYourSelf/new.cpp (revision 43)
@@ -0,0 +1,17 @@
1+#include <iostream>
2+using namespace std;
3+
4+int main()
5+{
6+ int *p;
7+ p = new int;
8+ if (!p){
9+ cout << "メモリ割り当てエラー\n";
10+ return 1;
11+ }
12+
13+ *p = 1000;
14+ cout << "pがさしている整数型は:" << *p << "\n";
15+ delete p;
16+ return 0;
17+}
\ No newline at end of file