-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclasses.cpp
More file actions
35 lines (29 loc) · 969 Bytes
/
Copy pathclasses.cpp
File metadata and controls
35 lines (29 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
//hello
//testing
//testing2
int x;
//creating a class
class lidar{
public: // access specifier (basically what can access these attributes)
int motorSpeed; // attribute
int lidarName = 2; // attribute
//sets motorSpeed (int) and lidarName (int)
lidar(int setMotorSpeed, int setLidarName){ //this is called a constructor, it is used to create new object from a class
std::cout << "You have create a new lidar object! \n";
motorSpeed = setMotorSpeed;
lidarName = setLidarName;
}
//returns the raw lidar data (int) as usable data (int) of the called upon lidar class
int readLidar(){
return lidarName;
}
};
//both readLidar and lidar are called "methods" these are basically functions that are specific to a class
int main() {
std::cout << "Please enter Lidar device name: ";
std::cin >> x;
lidar lidar1(2, x);
std::cout << lidar1.readLidar();
return 0;
}