Click here to Skip to main content
16,011,883 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: property pages Pin
vandanakaul9-Jan-02 17:37
vandanakaul9-Jan-02 17:37 
GeneralRe: property pages Pin
James R. Twine10-Jan-02 6:37
James R. Twine10-Jan-02 6:37 
GeneralRe: property pages Pin
vandanakaul10-Jan-02 18:37
vandanakaul10-Jan-02 18:37 
GeneralRe: property pages Pin
James R. Twine11-Jan-02 18:55
James R. Twine11-Jan-02 18:55 
GeneralRe: property pages Pin
vandanakaul14-Jan-02 21:08
vandanakaul14-Jan-02 21:08 
GeneralWorking with CArray Pin
8-Jan-02 21:16
suss8-Jan-02 21:16 
GeneralRe: Working with CArray Pin
Christian Graus8-Jan-02 22:17
protectorChristian Graus8-Jan-02 22:17 
GeneralRe: Working with CArray Pin
Joaquín M López Muñoz8-Jan-02 22:46
Joaquín M López Muñoz8-Jan-02 22:46 
Your post is a little hard to understand due to the fact that you haven't selected the "Ignore HTML" check, as Christian pointed out.
You need to provide the three canonical ctors (default, copy and assignment, this latter is not technically a ctor, but works similarly) for SDataRecord:
struct SDataRecord{
    SDataRecord()
    {
    }

    SDataRecord(const SDataRecord& r):
        csID(r.csID)
    {
        DataArray.Copy(r.DataArray);
    }

    SDataRecord& operator=(const SDataRecord& r)
    {
        csID=r.csID;
        DataArray.Copy(r.DataArray);
        return *this;
    }

    CString	csID;
    CArray <SSingleData, SSingleData> DataArray;
};
Why is this so? Well, the discussion is a little technical, but I think you might find it worth knowing. In C++, if you don't provide a copy ctor (the same goes for the assignment operator), then the compiler makes up one for you automatically. This default copy ctor simply copies all the members of the class one by one (what's called memberwise copy): so it's easy to figure out how to copy members of built-in types line ints, pointers and the like. With respect of members of non-primitive types (classes), the compiler uses their respective copy ctors if available: again, these copy ctors can be explicitly defined by the programmer of automatically generated.
What's happening to your SDataRecord? When the compiler tries to generate its copy ctor, first it deals with csID, and finds no problem, then it tries to locate the copy ctor for DataArray, whose type is CArray <SSingleData, SSingleData>, but CArray does not have a copy ctor (it derives from CObject which explicitly forbids copying between its instances). Conclusion: SDataRecord does not get an automatically generated copy ctor, and it's your task to write it yourself (same for the operator asignment). Altough CArray does not have copy ctor, its member function Copy does the same job.
One more subtlety: Once you define any ctor, the compiler does not provide an automatic default (no arguments) for you (as it's the case in SSingleData, for instance), so you have to include the definition for the default ctor as well.

PS: I second Christian's suggestion about quitting MFC containers and using instead std::vector and its merry STL companions.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
GeneralSaving CDC to Bmp File Pin
Abhishek Narula8-Jan-02 20:25
Abhishek Narula8-Jan-02 20:25 
GeneralRe: Saving CDC to Bmp File Pin
Rickard Andersson208-Jan-02 21:16
Rickard Andersson208-Jan-02 21:16 
GeneralRe: Saving CDC to Bmp File Pin
Christian Graus8-Jan-02 22:13
protectorChristian Graus8-Jan-02 22:13 
GeneralRe: Saving CDC to Bmp File Pin
Abhishek Narula8-Jan-02 22:23
Abhishek Narula8-Jan-02 22:23 
GeneralRe: Saving CDC to Bmp File Pin
Nish Nishant8-Jan-02 22:35
sitebuilderNish Nishant8-Jan-02 22:35 
GeneralRe: Saving CDC to Bmp File Pin
Abhishek Narula8-Jan-02 22:49
Abhishek Narula8-Jan-02 22:49 
GeneralRe: Saving CDC to Bmp File Pin
Christian Graus8-Jan-02 22:36
protectorChristian Graus8-Jan-02 22:36 
GeneralRe: Saving CDC to Bmp File Pin
Abhishek Narula8-Jan-02 22:45
Abhishek Narula8-Jan-02 22:45 
GeneralRe: Saving CDC to Bmp File Pin
Abhishek Narula8-Jan-02 22:46
Abhishek Narula8-Jan-02 22:46 
GeneralRe: Saving CDC to Bmp File Pin
Christian Graus8-Jan-02 22:51
protectorChristian Graus8-Jan-02 22:51 
GeneralENTER KEY Pin
8-Jan-02 17:43
suss8-Jan-02 17:43 
GeneralRe: ENTER KEY Pin
Eugene Pustovoyt8-Jan-02 18:58
Eugene Pustovoyt8-Jan-02 18:58 
GeneralRe: ENTER KEY Pin
Michael Dunn8-Jan-02 20:08
sitebuilderMichael Dunn8-Jan-02 20:08 
GeneralRe: ENTER KEY Pin
Nish Nishant8-Jan-02 20:22
sitebuilderNish Nishant8-Jan-02 20:22 
GeneralExlusive-or crypting Pin
Ever12348-Jan-02 15:18
Ever12348-Jan-02 15:18 
GeneralRe: Exlusive-or crypting Pin
Christian Graus8-Jan-02 17:40
protectorChristian Graus8-Jan-02 17:40 
GeneralRe: Exlusive-or crypting Pin
Malcolm McMahon8-Jan-02 23:30
Malcolm McMahon8-Jan-02 23:30 

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.