Unit 17 Test - UNIT 17 TEST 1 Answer the following...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: UNIT 17 TEST 1. Answer the following questions. a. What is the difference between public and private methods? b. How do you ensure that the copy constructor performs a deep copy? c. Why do we use the preprocessor directives #ifndef, #define, and #endif in header files? d. (true/false) const arguments to a method can only be modified by private methods. e. The variable named 'cout' is traditionally an instance of what class? a. public methods can be accessed outside of the class, when the class is included in a main function, the public methods go as well. private methods can only be accessed and changed inside the class. b. override the default copy methods (=) and then test to make sure by having a pointer on the original and seeing if the second has a different memory location. c. tells the compiler to include the code prior to compiling this way all methods and specific class variables are declared before running the code on them. d. false, you cannot change const arguments e. ostream 2. First create a character array that contains the 26 letters as shown here. char cAlphabet = {'a','b','c','d','e','f', 'g','h','i','j','k','l','m','n','o','p', 'q','r','s','t','u','v','w','x','y','z'}; Then create a vector of strings where the first string is 'a' and the second is 'bc', the third, 'def', etc. Create the number of strings requested by the user. Once you reach the letter z, start again with first letter in the alphabet. When you are done, print each vector to the screen. How many strings would you like to create? 8 a bc def ghij klmno pqrstu vwxyzab cdefghij #include <iostream> #include <vector> #include <string> using namespace std; int main() { int nStrings=0; string str1=" "; vector <string> myVector; char cAlphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; str1=cAlphabet; string str=" "; int letters = 0; int runoff = 0; str= str1.substr(0,26); cout<<str<<endl; cout<<"How many strings would like?"<<endl;cout<<"How many strings would like?...
View Full Document

This note was uploaded on 10/02/2011 for the course ME 205 taught by Professor Koen during the Spring '07 term at University of Texas.

Page1 / 8

Unit 17 Test - UNIT 17 TEST 1 Answer the following...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online