Red Light Work

Fork of realtimeMMLib by Graham Nicholson

Committer:
GTNicholson
Date:
Mon Oct 02 11:18:47 2017 +0000
Revision:
0:9f82ee1feae7
Initial Publish Version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GTNicholson 0:9f82ee1feae7 1 #include "mmdevice.h"
GTNicholson 0:9f82ee1feae7 2 #include <utility> // std::pair, std::make_pair
GTNicholson 0:9f82ee1feae7 3 #include <string> // std::string
GTNicholson 0:9f82ee1feae7 4 #include <iostream> // std::cout
GTNicholson 0:9f82ee1feae7 5
GTNicholson 0:9f82ee1feae7 6
GTNicholson 0:9f82ee1feae7 7 int mmdevice::getdata()
GTNicholson 0:9f82ee1feae7 8 {
GTNicholson 0:9f82ee1feae7 9 std::pair <std::string,double> product1; // default constructor
GTNicholson 0:9f82ee1feae7 10 std::pair <std::string,double> product2 ("tomatoes",2.30); // value init
GTNicholson 0:9f82ee1feae7 11 std::pair <std::string,double> product3 (product2); // copy constructor
GTNicholson 0:9f82ee1feae7 12
GTNicholson 0:9f82ee1feae7 13 product1 = std::make_pair(std::string("lightbulbs"),0.99); // using make_pair (move)
GTNicholson 0:9f82ee1feae7 14
GTNicholson 0:9f82ee1feae7 15 product2.first = "shoes"; // the type of first is string
GTNicholson 0:9f82ee1feae7 16 product2.second = 39.90; // the type of second is double
GTNicholson 0:9f82ee1feae7 17
GTNicholson 0:9f82ee1feae7 18 std::cout << "The price of " << product1.first << " is $" << product1.second << '\n';
GTNicholson 0:9f82ee1feae7 19 std::cout << "The price of " << product2.first << " is $" << product2.second << '\n';
GTNicholson 0:9f82ee1feae7 20 std::cout << "The price of " << product3.first << " is $" << product3.second << '\n';
GTNicholson 0:9f82ee1feae7 21 return 1;
GTNicholson 0:9f82ee1feae7 22 }