Poll
Question: Is it possible to link to c++ includes? I need to use the List template. If the dictionary is also available, that would be nice.
Yes - 3 (75%)
No - 0 (0%)
Maybe - 1 (25%)
Total Voters: 4

Pages: 1 2 [3]   Go Down
Author Topic: Linking to C++ includes, or having a Dictionary or List template?  (Read 2998 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can create a class that link a particular motor and speed value.

Code:
class motorWithSpeed
{
   int motorPin;
   int motorSpeed;

   motorWithSpeed(int pin);
   
   setSpeed(int speed);
   int getSpeed();
};

You can create an instance of that class:
Code:
motorWithSpeed speedy(3);

You can make that motor change speed:
Code:
speedy.setSpeed(160);

You can later determine how fast the motor is going:
Code:
int speedySpeed = speedy.getSpeed();

Only the class instance maintains the speed.


OMG, I didn't think of using a class! (herpaderp) Thankyou paul! I will love you forever <3
Logged

Global Moderator
Online Online
Brattain Member
*****
Karma: 506
Posts: 19120
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You used the word "object" in your very first post. And C++.

C++ is basically an object-oriented language. Objects are created by classes.

http://www.cplusplus.com/doc/tutorial/classes/

Quote
An object is an instantiation of a class. In terms of variables, a class would be the type, and an object would be the variable.
Logged


Pages: 1 2 [3]   Go Up
Jump to: