ankakusu
12/11/2007, 20:35
kodunu çalıştırmaya çalışıyorum ama
garip bir hata verdi. Tanımlı olan
fonksiyonu yok diyor. Nedenini anlayamadım.
1 #include <iostream>
2 using namespace std;
3
4 class Count
5 {
6 public:
7 void setX(int value) { x=value;}
8 void print() { cout << x << endl; }
9 private:
10 int x;
11 };
12
13 int main()
14 {
15 Count counter;
16 Count *counterPtr = &counter;
17 Count &counterRet = counter;
18
19 counter.setX(1);
20 counter.print();
21
22 counterRet.setX(2);
23 counterRet.print();
24
25 counterPrt->setX(3);
26 counterPrt->print();
27 return 0;
28 }
verdiği hata:
count.cpp: In function 'int main()':
count.cpp:25: hata: 'counterPrt' was not declared in this scope
garip bir hata verdi. Tanımlı olan
fonksiyonu yok diyor. Nedenini anlayamadım.
1 #include <iostream>
2 using namespace std;
3
4 class Count
5 {
6 public:
7 void setX(int value) { x=value;}
8 void print() { cout << x << endl; }
9 private:
10 int x;
11 };
12
13 int main()
14 {
15 Count counter;
16 Count *counterPtr = &counter;
17 Count &counterRet = counter;
18
19 counter.setX(1);
20 counter.print();
21
22 counterRet.setX(2);
23 counterRet.print();
24
25 counterPrt->setX(3);
26 counterPrt->print();
27 return 0;
28 }
verdiği hata:
count.cpp: In function 'int main()':
count.cpp:25: hata: 'counterPrt' was not declared in this scope