Click here to Skip to main content
16,008,490 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: directory browser Pin
Tomasz Sowinski19-Aug-02 10:16
Tomasz Sowinski19-Aug-02 10:16 
GeneralRe: directory browser Pin
Renjith Ramachandran19-Aug-02 10:23
Renjith Ramachandran19-Aug-02 10:23 
GeneralRe: directory browser Pin
ns19-Aug-02 10:41
ns19-Aug-02 10:41 
GeneralRe: directory browser Pin
Ravi Bhavnani19-Aug-02 11:48
professionalRavi Bhavnani19-Aug-02 11:48 
GeneralRe: directory browser Pin
ns20-Aug-02 1:47
ns20-Aug-02 1:47 
GeneralRe: directory browser Pin
ns20-Aug-02 2:15
ns20-Aug-02 2:15 
GeneralRe: directory browser Pin
Ravi Bhavnani20-Aug-02 4:37
professionalRavi Bhavnani20-Aug-02 4:37 
GeneralSTL vector push_back( ) copy c'stor question Pin
JohnnyG19-Aug-02 10:05
JohnnyG19-Aug-02 10:05 
I'm using a vector to save objects. Looking at STL documentation it says that it will make a copy of the objects for the vector when using push_back(). I'm probably doing this wrong but it does not appear to make copies of my data.

To make the copy, I have a default constructor which does nothing but clear all of the object's attributes. Next, I have an operator= overload but it never gets called when calling push_back(). I thought that a copy constructor used operator= or do I have to make it explicit like this??? :

class myObj
{
public:
   myObj() { attribute1 = 0; attribute2 = 0;} // default constructor

   myObj(myObj& obj)   // copy constructor ?????
   {
     *this = obj;
   }

   // copy from one obj to another
   myObj& operator=(const myObj& objPassed) 
   {
      attribute1 = objPassed.attribute1;
      attribute2 = objPassed.attribute2;

      return *this;
   }
private:
   long attribute1, attribute2;

};

All I have now is the default constructor and operator= overloaded. I thought the compiler provided a default copy constructor.

My implementation code looks like:
myObj theObj;

for(int i = 0; i < numObjsToBuild; i++)
{
   // yeah, yeah, accessor functions here instead. just an example :)
   theObj.attribute1 = value1;
   theObj.attribute2 = value2;
   myObjArray.push_back(theObj);
}

Anything wrong here?
GeneralRe: STL vector push_back( ) copy c'stor question Pin
Tomasz Sowinski19-Aug-02 10:15
Tomasz Sowinski19-Aug-02 10:15 
GeneralRe: STL vector push_back( ) copy c'stor question Pin
Stuart Dootson19-Aug-02 14:17
professionalStuart Dootson19-Aug-02 14:17 
GeneralRe: STL vector push_back( ) copy c'stor question Pin
JohnnyG20-Aug-02 4:25
JohnnyG20-Aug-02 4:25 
GeneralWinsock: Socket disconnection Pin
Le centriste19-Aug-02 9:37
Le centriste19-Aug-02 9:37 
GeneralRe: Winsock: Socket disconnection Pin
Ernest Laurentin19-Aug-02 9:52
Ernest Laurentin19-Aug-02 9:52 
GeneralRe: Winsock: Socket disconnection Pin
unregistered19-Aug-02 19:49
unregistered19-Aug-02 19:49 
GeneralToolbar in Internet Explorer Pin
Tzoockee19-Aug-02 9:22
Tzoockee19-Aug-02 9:22 
GeneralRe: Toolbar in Internet Explorer Pin
Michael Dunn19-Aug-02 10:53
sitebuilderMichael Dunn19-Aug-02 10:53 
QuestionHow to know the user switch to another MDI child window? Pin
Vincent Ye19-Aug-02 8:40
Vincent Ye19-Aug-02 8:40 
AnswerRe: How to know the user switch to another MDI child window? Pin
Neville Franks19-Aug-02 10:49
Neville Franks19-Aug-02 10:49 
GeneralTransform WORD data to UNICODE Pin
Eugene Pustovoyt19-Aug-02 8:05
Eugene Pustovoyt19-Aug-02 8:05 
GeneralRe: Transform WORD data to UNICODE Pin
Stuart Dootson19-Aug-02 8:28
professionalStuart Dootson19-Aug-02 8:28 
GeneralRe: Transform WORD data to UNICODE Pin
Michael Dunn19-Aug-02 10:54
sitebuilderMichael Dunn19-Aug-02 10:54 
GeneralRe: Transform WORD data to UNICODE Pin
Eugene Pustovoyt19-Aug-02 19:24
Eugene Pustovoyt19-Aug-02 19:24 
Generaladdchunk doesnt exist --blob question Pin
ns19-Aug-02 7:52
ns19-Aug-02 7:52 
GeneralRe: addchunk doesnt exist --blob question Pin
Joel Lucsy19-Aug-02 17:58
Joel Lucsy19-Aug-02 17:58 
GeneralSend messages over msn network Pin
JDMoore19-Aug-02 7:41
JDMoore19-Aug-02 7:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.