Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:727520485a55, committed 2013-02-21
- Comitter:
- simon
- Date:
- Thu Feb 21 22:14:09 2013 +0000
- Parent:
- 0:16feaaa89263
- Commit message:
- Version eliminating pointers/new
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file | 
--- a/main.cpp	Thu Feb 21 22:11:41 2013 +0000
+++ b/main.cpp	Thu Feb 21 22:14:09 2013 +0000
@@ -1,24 +1,26 @@
-#include "mbed.h"
-//test setting up an mbed pin as a class member initialized in the constructor
-class flasher
-{
-public:
-    DigitalOut* DO1;
-    DigitalOut* DO2;
-    flasher() { DO1 = new DigitalOut(LED1); DO2 = new DigitalOut(LED2);}  //establish LED1 to flash
-    void flash(void) 
-    { 
-    *DO1 = 1; wait(0.25); *DO1 = 0; wait(0.25);
-    *DO2 = 0; wait(0.25); *DO2 = 1; wait(0.25);
-    }
-};
- 
- 
-int main() {
-    flasher ff;
-    
-    while(1) {
-        ff.flash();
-        wait(0.25);
-    }
+#include "mbed.h"
+//test setting up an mbed pin as a class member initialized in the constructor
+class flasher
+{
+public:
+    DigitalOut DO1;
+    DigitalOut DO2;
+
+    flasher() : DO1(LED1), DO2(LED2) {}
+
+    void flash(void) 
+    { 
+    DO1 = 1; wait(0.25); DO1 = 0; wait(0.25);
+    DO2 = 0; wait(0.25); DO2 = 1; wait(0.25);
+    }
+};
+ 
+ 
+int main() {
+    flasher ff;
+    
+    while(1) {
+        ff.flash();
+        wait(0.25);
+    }
 }
\ No newline at end of file