0

So I have this test and while studying I came up with the following question that I don't even understand (nor the question or the answer)

I know coding, I just don't understand all the nonsense they try to teach us. So the question is:

Q: The class string has pointers to an array of char. Which of the three copy control solutions for pointers, does the class must define?

A: value_like semantics

I do know that string is an array of chars, but I don't know what are "copy control solutions", I'm not even sure what is copy control (copy constructor maybe??) and what is value_like semantics??

Hope the question makes sense, it was translated from Hebrew.

Thanks for your help :)

  • 10
    I guess this is what happens when you dismiss things as "nonsense" right until you need to study for a test. – R. Martinho Fernandes Jul 25 '13 at 11:47
  • 1
    That "nonsense" is rather important if you want to write working code. [Here](http://stackoverflow.com/questions/4172722/what-is-the-rule-of-three) is a good overview of how object copying works in C++. – Mike Seymour Jul 25 '13 at 11:48
  • paste it in heb, maybe it will make more sense... and my intuition is Copy constructors too. – Tomer W Jul 25 '13 at 11:48
  • 1
    If the question asks about "the class string", it most likely means [`std::string`](http://en.cppreference.com/w/cpp/string/basic_string), and not old C-style strings. – Some programmer dude Jul 25 '13 at 11:53

1 Answers1

3

"Copy control solutions" probably refers to implementation strategies for copy constructor and copy assignment. I would assume that your textbooks at some point list the three solutions for pointers, given the peculiarly specific wording of the question.

Therefore, look them up and understand what they are about. Knowing how to implement copying for resource-managing objects is one of the most essential language-specific skills for a C++ programmer.

Sebastian Redl
  • 69,373
  • 8
  • 123
  • 157