Home > Software engineering >  Error C2280 CArray nested, add (), 100
Error C2280 CArray nested, add (), 100

Time:09-24

I first defines two Struct, defined as follows:
//a single securities node data (a Bar)
Struct CHqData
{
CTime datetime.//quotation date/time
Double lastprice,//latest price
Double open;//the opening
Double close;//close
Double high;//the highest
Double low;//the lowest
Double vol.//volume
Double amt.//turnover
};
//a single securities of sequence data
Struct CHqArray
{
Cstrings stkcode;//code of securities;
Cstrings windcode;//stock code (wonder)
Cstrings period;//cycle -- the 'D', date line, 'W' weekly, 'M' on the line, 'Y' in the line, 't' tick data, '1' for a minute, '30'...
CArray HqDataArray;//market sequence
};

A CArray CHqArray members of nested, and then set up a set of global variables, used to store all the stock market sequence
CArray HqBuff_Custom; Market data cache//custom cycle;

Perform assignment
CHqArray tempHqArray;
TempHqArray. Stkcode="600191";
TempHqArray. Windcode="600191. SH";
TempHqArray. Period="M";
TempHqArray. HqDataArray. Add (ahqdata);//ahqdata from external incoming (assignment part omitted)

HqArray. Add (tempHqArray);

Compile time, versus an error C2280 CHqArray & amp; "" CHqArray: : operator=(const CHqArray & amp;) ": try reference function of deleted

Search the along while, also can not find the answer, please expert advice, thank you detailed point, 100 reward points

CodePudding user response:

Don't see where you hqArray defined

CodePudding user response:

Sorry, hqArray. Add (tempHqArray); Is hqBuff_Custom. Add (tempHqArray)

CodePudding user response:

The basic types of need overloaded operator=

 
//a single securities of sequence data
Struct CHqArray
{
Cstrings stkcode;//code of securities;
Cstrings windcode;//stock code (wonder)
Cstrings period;//cycle -- the 'D', date line, 'W' weekly, 'M' on the line, 'Y' in the line, 't' tick data, '1' for a minute, '30'...
CArray HqDataArray;//market sequence

Virtual void operator=(const CHqArray & amp; Other)
{
If (this!=& amp; Other)
{
Stkcode=other. Stkcode;
Windcode=other. Windcode;
Period=other. Period;
HqDataArray. Copy (other. HqDataArray);
}
}
};

CodePudding user response:

Added a copy constructor and overloaded assignment operator problem solving:
//a single securities of sequence data 
Struct CHqArray
{
Cstrings stkcode;//code of securities;
Cstrings windcode;//stock code (wonder)
Cstrings period;//cycle -- the 'D', date line, 'W' weekly, 'M' on the line, 'Y' in the line, 't' tick data, '1' for a minute, '30'...
CArray HqDataArray;//market sequence

CHqArray () {}
CHqArray (const CHqArray& O)
{
If (& amp; O!=this)
{
Stkcode=grown tkcode;
Windcode=o.w indcode;
Period=o.p eriod.
}
}
CHqArray operator=(const CHqArray& O)
{
If (& amp; O!=this)
{
Stkcode=grown tkcode;
Windcode=o.w indcode;
Period=o.p eriod.
}
Return * this;
}
};

Note:
1) please according to the business need to complete the copy constructor and overloaded assignment operator
Principle 2) please make your own baidu
3) please give me a message if you have any questions

CodePudding user response:

Sorry, standards of writing as follows:
//a single securities of sequence data 
Struct CHqArray
{
Cstrings stkcode;//code of securities;
Cstrings windcode;//stock code (wonder)
Cstrings period;//cycle -- the 'D', date line, 'W' weekly, 'M' on the line, 'Y' in the line, 't' tick data, '1' for a minute, '30'...
CArray HqDataArray;//market sequence

CHqArray () {}

Virtual CHqArray& Operator=(const CHqArray& O)
{
If (& amp; O!=this)
{
Stkcode=grown tkcode;
Windcode=o.w indcode;
Period=o.p eriod.
}
Return * this;
}
};

CodePudding user response:

reference 5 floor xuzzzhen123 reply:
sorry, standards of writing as follows:
//a single securities of sequence data 
Struct CHqArray
{
Cstrings stkcode;//code of securities;
Cstrings windcode;//stock code (wonder)
Cstrings period;//cycle -- the 'D', date line, 'W' weekly, 'M' on the line, 'Y' in the line, 't' tick data, '1' for a minute, '30'...
CArray HqDataArray;//market sequence

CHqArray () {}

Virtual CHqArray& Operator=(const CHqArray& O)
{
If (& amp; O!=this)
{
Stkcode=grown tkcode;
Windcode=o.w indcode;
Period=o.p eriod.
}
Return * this;
}
};