This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Eng101W07 Sec 100 Homework 6: Jumping into C++ Due Friday, March 16, 2007, by 6 PM EDT 1 Upload to CTools Site Name: FILL-IN Lab GSI: FILL-IN Lab Section #: FILL-IN A. Preparatory work . • Read through the latter half of Eckel’s Chapter 2. • For more on the string library, download Eckel’s second volume and see his chapter on the string library. • Don’t get hung up on too much on the terminology and the details! Make liberal use of the provided sample code. We’re going to jump-start ourselves in C++ by tackling some larger problems. They’re more interesting (frankly) than writing code that reverses the letters in the string ‘abracadabra’ but they can become needlessly hard if you don’t re-use and expand on the code I provide. • Much of the trouble with C++ material on the web is that it assumes you’ve been programming for awhile and that you’re an expert in C. So sad…and so not necessary. Almost all of the ideas (and conveniences) you’re going to find in C++ are ones we’ve already encountered in Matlab. Soooooo…resist the temptation to go out scrounging. Instead, I recommend the following site http://www.cplusplus.com/reference/ This is probably the most stripped-down “just the facts” treatment of basic datatypes and functions for the C++ classes I’ve been able to find that doesn’t involve putting money in some publisher’s pocket. Use it! And on my end, I will try to assign tasks with sufficient numbers of boundaries that you won’t stray into unproductive “experiments” in trying to get your code to run. 1 Heh heh heh – I almost forgot! B. Answer the following questions. 1. [5 pts.] Recognizing when your programming error was simple. a. Eliminate the line “using namespace std;” from OneWordWonder.cpp, save your result to a new file, and compile. In the space below, insert the contents of your terminal window from your compile line to the end of (any) error messages. [udhcp-macvpn-611:~/RENOVATE/Eng101/cpp_projects] gregoryw% g++ OneWordWonder_HW6_1a.cpp OneWordWonder_HW6_1a.cpp: In function 'int main()': OneWordWonder_HW6_1a.cpp:5: error: 'string' was not declared in this scope OneWordWonder_HW6_1a.cpp:5: error: expected `;' before 'myinput' OneWordWonder_HW6_1a.cpp:6: error: 'cout' was not declared in this scope OneWordWonder_HW6_1a.cpp:7: error: 'endl' was not declared in this scope OneWordWonder_HW6_1a.cpp:8: error: 'cin' was not declared in this scope OneWordWonder_HW6_1a.cpp:8: error: 'myinput' was not declared in this scope b. Edit your saved file so that every occurrence of string , cin , and cout is prefixed by std:: . In other words, cin becomes std::cin . Compile your program. In the space below, insert the contents ....
View Full Document
This homework help was uploaded on 04/04/2008 for the course ENGR 101 taught by Professor Ringenberg during the Fall '07 term at University of Michigan.
- Fall '07