Unit 17 Test - UNIT17TEST 1. a b c...

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

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
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; cin>>nStrings;
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern