


So i haven't my MSDN cd at workand i don't know/rememeber how i can make a copy of an object with this:i have a pointer OBJECT * LPsrc; // it's a pointer to a valide objecti have also a containerOBJECT dst; // it's an object I WANT COPY THE OBJECT POINTED by "LPsrc" into "dst" !!...
Hi!I'm new to this and I have the following problem:I want to copy the contence from one object to an other by "pointing to the memory". The usual way to copy an CObject is member by member and as the structure is very large it would be to slow (minutes). The classes I use are like this:class C...
my task is really simple but I have some problems solving it. I gues it is a matter of seconds for someone to tell me how to Write a program copy_file that copies one file to another. The file names are specified on the command line. For examplecopy_file data1.txt data2.txt10x in advance!Victor Kova...
I have a class (lets call it A) which has a protected ostream member. I want to be able to pass an ostream through the constructor and store the copy in the protected member (the copy ensures that if the original ostream passed to the constructor goes out of scope, the classes ostream is still valid...
i have CSimpleArray<ImageAndPath> ImageAndPaths = CSimpleArray<ImageAndPath>();ImageAndPath is defined below:class ImageAndPath{public: ImageAndPath(const ImageAndPath& iap) { *this = iap; bCopy = true; } ImageAndPath(const CString& str) { USES_CONVERSION; path = str; pImage = new B...
I created this very small scenario because I can't understand why the wrong constructors appear to get called.class A{ char* m_Ptr; static char Count;public: A() { m_Ptr = new char[100]; memset(m_Ptr, Count, 100); Count++; } ~A() {delete[] m_Ptr;} A(const A& RHS) { m_Ptr...
could sum1 explain to me when does copy construction occur in c++. & what is default copying & wat problems can it introduce....
Say I have a simple function that returns the first 5 characters of a string:char* first(const char* lpStr){ int nLen = strlen(lpStr); static char* lpTemp = (char*) malloc(6); for(int i = 0; i < 5; i++) { lpTemp[i] = lpStr[i]; } lpTemp[i] = '\0'; return lpTemp;}Is this the correct way...
Calling code (main.cpp): //make a duplicate of kb called kb2 Keyboard kb2(kb);Copy constructor (Layout.cpp -- need to change the file name eventually):Keyboard::Keyboard(const Keyboard &rhs){ name = rhs.getName(); //string score = rhs.getScore(); //int //etc..}(line: name = rhs.getName();...
How do I write a copy constructor that transfers ownership?...
Hello,I have a class CNodeTest derived from CBaseNode. I have the following code whihc does not compile:CNodeTest CNodeTest ::Complement(){ CNodeTest comp; // TODO: change some math here return comp;}CBaseNode* CNodeTest ::ComplementNew(){ return new CNodeTest(Complement());}I know a default copy...
very newbie question - :blush: what is copy constructor and why use it?Avi....
I get an error when compiling the follow code:class SomeType{public: SomeType() { }; SomeType(SomeType& x) {};};std::vector<SomeType> array;SomeType sometype1;array.push_back(sometype1);I get:error C2558: class 'SomeType' : no copy constructor availableBut I defined the copy construc...
Hi.. im having some problems here a C++ assignment. i hope someone can help methese are included in the header file1- BasicArray(const BasicArray&); //copy constructorhow do i define this? and can i do it without:BasicArray& operator = (const BasicArray& rhs); //assignmentwhat is the relationship be...
I'm really green at this, but I'm trying to get my head wrapped around copy constructors and after about 2 hours I'm no further ahead. All I want to do is push_back a new object into a vector of that object.I'll post the code first, then the error i'm getting down at the bo...
