初学者关于类的问题
我是初学者,自学,编了一段代码,但是GUN老是报错,那位高手,帮忙看下1 #include <iostream>
2
3 class Tricycle
4 {
5 public:
6 int getSpeed() ;
7 void setSpeed(int speed);
8 void pedal();
9 void break();
10 private:
11 int speed;
12 };
13
14 int Tricycle::getSpeed()
15 {
16 return speed;
17 }
18
19 void Tricycle::setSpeed(int speed)
20 {
21 if(newSpeed >= 0)
22 {
23 speed = newSpeed ;
24 }
25 }
26
27 void Tricycle::pedal()
28 {
29 setSpeed(speed + 1);
30 std::cout<<"\nPedaling;tricycle speed"<<speed<<"mph\n";
31 }
32
33 void Tricycle::break()
34 {
35 setSpeed(speed - 1);
36 std::cout<<"\nBreaking;tricycle speed"<<speed<<'mph\n";
37 }
38
39 int main()
40 {
41 Tricycle man;
42 man .setSpeed(5);
43 man .pedal();
44 man .pedal();
45 man .pedal();
46 man .break();
47 man .break();
48 return 0;
49 }
50
报错在9,21,33,36,46,47行,谁帮忙看一下??