Question

22. Given the following code namespace globalType void printResultO which of the following statements is needed to access printResult? a. globalType.printResulto b. globalType: :printResult: c. globa1Type printResult0 d. globa1Type:printResult0 23. Consider the following statements: struct rectangleData double length: double width; double area double perimeter: rectangleData bigRect: Which of the following statements is valid in C4+ a. cinbigRect::length b. cout << bigRect.length c cout < bigRect d cout << length: 24. What is the output of the following statements string strlJohn string str2 Smith is taking Csc2000 str2.replace (0, 5, str1) cout <s str2 a. Johnis taking CSC2000 b. JohnSmith is taking CSC2000 c. John is taking CSC2000 d. is taking CSC2000 functic 25. A member fiunction of a class that modifies the valucto) of the data membero)is alled alo)fncic c. constructor a. accessor b. mutator d. destructor
0 0
Add a comment Improve this question Transcribed image text
Answer #1

22 b

a function in any namespace can be accessed in the form of mynamespace::myfunction

example

std::cout << "Dummy\n"; 
example::dummy();

23 b

structure elements can be accessed using dot or an arrow.

in this case it is accessed as bigRect.length

if bigRect was a pointer variable, then the members are accessed as bigRect->length or (*bigRect).length

24 c

0 is the first position in str2 which is S

5 is the number of characters to replace, which is Smith

when str1 replaces you get the answer as mentioned in c.

25 b

accessor functions are those functions that are used to access member variables.

mutator functions are those functions that are used to modify member variable values.

eg. myclass m

class Toto{
 private :
  int _age;

 public :
  void SetAge(int);
  int GetAge(); 

};

void Toto::SetAge(int age){
 _age = age;
}
int  Toto::GetAge(){
return  _age;
}

SetAge is a mutator

GetAge is a accessor

please rate the answer

Add a comment
Know the answer?
Add Answer to:
Given the following code namespace globalType { void.printResult(): } which of the following statements is needed...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • QUESTION 10 Which of the following is the correct definition of a function that calculates the...

    QUESTION 10 Which of the following is the correct definition of a function that calculates the area of a rectangle by multiplying its length by its width? The length and width parameters are double values and the function returns a double. double area (double length, double width) return lengthwidth double area( double length, double width) double area length width return double area(double length, width) return length width area(double length, double width) return length width; QUESTION 11 What is the output...

  • SCREENSHOTS ONLY PLEASE!!! DON'T POST ACTUAL CODE PLEASE LEAVE A SCREENSHOT ONLY! ACTUAL TEXT IS NOT NEEDED!!! myst...

    SCREENSHOTS ONLY PLEASE!!! DON'T POST ACTUAL CODE PLEASE LEAVE A SCREENSHOT ONLY! ACTUAL TEXT IS NOT NEEDED!!! mystring.h: //File: mystring1.h // ================ // Interface file for user-defined String class. #ifndef _MYSTRING_H #define _MYSTRING_H #include<iostream> #include <cstring> // for strlen(), etc. using namespace std; #define MAX_STR_LENGTH 200 class String { public: String(); String(const char s[]); // a conversion constructor void append(const String &str); // Relational operators bool operator ==(const String &str) const; bool operator !=(const String &str) const; bool operator >(const...

  • In C++ Given the declaration 
char str1[15];
char str2[15] = "Good day"; 
mark the following statements...

    In C++ Given the declaration 
char str1[15];
char str2[15] = "Good day"; 
mark the following statements as valid or invalid. If invalid, explain why. NOTE: Assume that the directive #define _CRT_SECURE_NO_WARNINGS has been entered appropriately in the program. a) if(strlen(str1)>=strlen(str2)) str1 = str2; b) if(strcmp(str1,str2))
 cout << "The strings are equal";

  • QUESTION 1 What is the output of the following code snippet? int main() { bool attendance...

    QUESTION 1 What is the output of the following code snippet? int main() { bool attendance = false; string str = "Unknown"; attendance = !(attendance); if (!attendance) { str = "False"; } if (attendance) { attendance = false; } if (attendance) { str = "True"; } else { str = "Maybe"; } cout << str << endl; return 0; } False True Unknown Maybe QUESTION 2 What is the output of the following code snippet? #include <iostream> #include <string> using...

  • In the code (C++) below, if you input 2 as length and 4 as width, the...

    In the code (C++) below, if you input 2 as length and 4 as width, the output is: Enter the rectangle's length: 2 Enter the rectangle's width: 4 Length: 2 | Width: 4 | Area: 8 | Perimeter:12 We worked on this code during class, but there were some things that I did not understand. 1) how does compiler read"l" as length, "w" as width, etc.? I thought you had to update it first, like "w=width." 2) i thought you...

  • Take the following C++ code and add to it the following: Write a program that reads...

    Take the following C++ code and add to it the following: Write a program that reads a string and outputs the number of times each lowercase vowel appears in it. Your program must contain a function with one of its parameters as a char variable, and if the character is a vowel, it increments that vowel's count. #include<iostream> #include<string> using namespace std; int countVowel(char, char); int main(void) { string str1; int countA = 0; int countE = 0; int countI...

  • It's a C++ code. 2. Answer the following questions in a word document. 6. What is...

    It's a C++ code. 2. Answer the following questions in a word document. 6. What is the output of the following C++ code? (2, 3) int inti - 26 int int2 = 45; int intPtr - Einti; int int2Ptr - Gint2: intPtr -89; int2Ptr - 623 intiptr - int2Ptr intPtr - 80 intl -57 cout << inti «..« int2 << endl; cout << *intiptr «« int2Ptr << endl; 7. Given the following statements: int num; int numPtr write C++ statements...

  • C++ program. int main() {    Rectangle box;     // Define an instance of the Rectangle class...

    C++ program. int main() {    Rectangle box;     // Define an instance of the Rectangle class    double rectWidth; // Local variable for width    double rectLength; // Local variable for length    string rectColor;    // Get the rectangle's width and length from the user.    cout << "This program will calculate the area of a\n";    cout << "rectangle. What is the width? ";    cin >> rectWidth;    cout << "What is the length? ";    cin >>...

  • Task: Tasks to complete: ------------------------------------------------------------------------------------------------------------------------------------------ given code: --------------------...

    Task: Tasks to complete: ------------------------------------------------------------------------------------------------------------------------------------------ given code: ------------------------------------------------------------------------------------------------------------------------------------------ main.cpp #include #include "rectangleType.h" using namespace std; // part e int main() { rectangleType rectangle1(10, 5); rectangleType rectangle2(8, 7); rectangleType rectangle3; rectangleType rectangle4; cout << "rectangle1: " << rectangle1 << endl; cout << "rectangle2: " << rectangle2 << endl; rectangle3 = rectangle1 + rectangle2;    cout << "rectangle3: " << rectangle3 << endl; rectangle4 = rectangle1 * rectangle2;    cout << "rectangle4: " << rectangle4 << endl; if (rectangle1 > rectangle2) cout << "Area...

  • Hi I was hoping to get some help with my code for this problem. I don't...

    Hi I was hoping to get some help with my code for this problem. I don't know how to correctly read a txt file and the difference between using string and cstring. My code is at the bottom please help thanks. 1. Create the following “data.txt” file. Each record consists of customer's name and their balance: Maria Brown 2100.90 Jeffrey Jackson 200.20 Bernard Smith 223.10 Matthew Davenport 1630.20 Kimberly Macias 19100.90 Amber Daniels 2400.40 The records in the file will...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT