[CSI] cs1b questions

Mikhail Nesterenko mikhail at cs.kent.edu
Thu May 12 13:50:48 EDT 2016


rs wrote:
> 1. With overloaded assignment operator since object on the left already
> exist, if its size is same as the one on the right, is it correct if the 3
> statements for size, delete, and pointer reassignment are dropped and only
> using the for loop the value are copied from right to left?

certainly. And it would be a useful optimization too. For the curious,
here is a discussion as to how vector class is implemented internally

  http://codefreakr.com/how-is-c-stl-implemented-internally/

> 
> 2. What is the style for namesapce use in header file?

There should be no executable code in the header files. Thus, only
function prototypes and class definitions should be in the namespace
definition. The function definitions should be in the source files.

Thanks,
--
Mikhail


More information about the cs13001 mailing list