Questions

Hello, I have some questions I'm unsure about as I review. They are true and false


1.Global constants have no side effects in a program?
I think this is false but. I'm unsure. If you make a variable constant then the value will not change so I"m not to sure about the side effects if the value is fixed.

2.Suppose that str1 and str2 are string variables. After the following statements execute, the value of str2
is "abcxyz".

str1 = "abc";
str2 = str1 + "-";
str2 = str2 + "xyz";

I know this is false it would abc-xyz. My question is when can you not add two strings. My teacher gave an example and said at least one has to be this. I don't know what the the this was.

3. Lastly, In C++, the terms object and members mean the same thing.

I think false an object consists of the memembers. Is this correct.



THANK YOU DETROIT! lol:)
for the 2th,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <string>
using namespace std;

int main(){
    string str1 = "abc";
    string str2 = "efg";
    string str3;
    
    str3 = str1+str2;
    
    cout << str1 << endl;
    cout << str2 << endl;
    cout << str3 << endl;
    
    system("pause");
    return 0;
    
}


When u add 2 string variable, they will 'connect ' together'.

And object is not same as member, class can have function and variable. IF i am right, member is the function or variable in the class. And u can create an object which has the variable and function(member) of the class.
Last edited on
And object is not same as member, class can have function and variable. IF i am right, member is the function or variable in the class. And u can create an object which has the variable and function(member) of the class.

Thats what I think also.
Thanks dooode
Topic archived. No new replies allowed.