CArray problem
-
CArray CMyClass::MyFunction(const char*,const char*) { CArray tmp; CString str_component = "test"; tmp.Add(str_component); return tmp; } =======Compile========= error C2558: class 'CArray' : no copy constructor available What's wrong ? What could I do (show me the example please)? Thanks a lot for your kindness
-
CArray CMyClass::MyFunction(const char*,const char*) { CArray tmp; CString str_component = "test"; tmp.Add(str_component); return tmp; } =======Compile========= error C2558: class 'CArray' : no copy constructor available What's wrong ? What could I do (show me the example please)? Thanks a lot for your kindness
// make sure you have this include file: #include //Put this in your header CArray yourArray; //This is how you would do it in your cpp file yourArray.InsertAt(0,YourString); Try this, my first response wasn't formatted correctly. After a poor performance in London in 1899, Steinitz went insane and died a year later on August 12, 1900 at Wards Island, N.Y.
-
// make sure you have this include file: #include //Put this in your header CArray yourArray; //This is how you would do it in your cpp file yourArray.InsertAt(0,YourString); Try this, my first response wasn't formatted correctly. After a poor performance in London in 1899, Steinitz went insane and died a year later on August 12, 1900 at Wards Island, N.Y.
heyyyyyyyy just repaly after knowing the problem.he wants to retun a CArray from a function... :suss: me also face the same problem Renjith-The CPian.
-
heyyyyyyyy just repaly after knowing the problem.he wants to retun a CArray from a function... :suss: me also face the same problem Renjith-The CPian.
> he wants to retun a CArray from a function... > me also face the same problem Doesn't work! Solution: use std::vector and fire the responsible MS-Programmer :-D Really: To return a CArray by value requires the use of the copy constructor to copy the object (as the local instance will be destructed on return from the function. But-CArray has got no copy constructor, meaning CArray is almost useless. Greetings Jan-Henner Wurmbach
-
> he wants to retun a CArray from a function... > me also face the same problem Doesn't work! Solution: use std::vector and fire the responsible MS-Programmer :-D Really: To return a CArray by value requires the use of the copy constructor to copy the object (as the local instance will be destructed on return from the function. But-CArray has got no copy constructor, meaning CArray is almost useless. Greetings Jan-Henner Wurmbach
jhwurmbach wrote: CArray is almost useless. YES YES YES YES YES !!!!! Christian I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002 Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
-
CArray CMyClass::MyFunction(const char*,const char*) { CArray tmp; CString str_component = "test"; tmp.Add(str_component); return tmp; } =======Compile========= error C2558: class 'CArray' : no copy constructor available What's wrong ? What could I do (show me the example please)? Thanks a lot for your kindness
Instead of returning a CArray (which is impossible no matter what you do since it's a template class; but that's another story) do this:
void CMyClass::MyFunction(CStringArray& a)
{
CString str_component = "test";
a.add(str_component);
}#include "afxtempl.h" to use the class 'CStringArray'. To use 'MyFunction' do like this:
void CMyClass::AnotherFunction()
{
CStringArray myArray;
this->MyFunction(myArray);
}After the call to 'MyFunction' the string is still added since the array is sent by reference. And there is no need for a copy constructor for the same reason. Sprudling