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.
Diff: main.cpp
- Revision:
- 3:12ac28cf86f0
- Parent:
- 2:e3ebd2ae8892
diff -r e3ebd2ae8892 -r 12ac28cf86f0 main.cpp --- a/main.cpp Mon Mar 03 06:27:29 2014 +0000 +++ b/main.cpp Fri Mar 07 08:28:03 2014 +0000 @@ -20,7 +20,7 @@ void setName(char* n, int i){ name.assign(n, i );} string getName() { return name; } - void setId(int i) { id = i; } + void incId() { id++; } int getId(){ return id; } private: @@ -91,8 +91,7 @@ } int main() { - string name=""; - int id(0); + string name=""; pc.attach(&rxCallback, Serial::RxIrq); wait(1); @@ -103,7 +102,7 @@ name.assign(inCmd, strlen(inCmd) ); - Student s(name, id); + Student s(name, 0); pc.printf("\r\nhello %s, your id is %d\r\n", s.getName().c_str(), s.getId()); printMainMenu(); @@ -118,7 +117,7 @@ case NAMECHANGED: s.setName(inCmd, sizeof(inCmd) ); - s.setId(++id); + s.incId( ); pc.printf(">> Your name has been set to %s\r\n", s.getName().c_str()); printMainMenu(); state = IDLE;