Click here to Skip to main content
15,888,047 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Calculating decimal places - Pin
David Crow16-Oct-18 3:20
David Crow16-Oct-18 3:20 
AnswerRe: Calculating decimal places - Pin
ptr_Electron16-Oct-18 3:29
ptr_Electron16-Oct-18 3:29 
GeneralRe: Calculating decimal places - Pin
David Crow16-Oct-18 3:38
David Crow16-Oct-18 3:38 
GeneralRe: Calculating decimal places - Pin
leon de boer16-Oct-18 15:28
leon de boer16-Oct-18 15:28 
QuestionRe: Calculating decimal places - Pin
CPallini16-Oct-18 2:48
mveCPallini16-Oct-18 2:48 
AnswerRe: Calculating decimal places - Pin
ptr_Electron16-Oct-18 2:55
ptr_Electron16-Oct-18 2:55 
GeneralRe: Calculating decimal places - Pin
CPallini16-Oct-18 3:11
mveCPallini16-Oct-18 3:11 
QuestionUsing assignment operator = for a class with const memeber variables? Pin
Member 140109547-Oct-18 12:52
Member 140109547-Oct-18 12:52 
I'm doing an assignment and it was told that SIZE of the array has to be const and also that I will need to create an assignment operator, but idk maybe my lecturer didn't think about it?
I have this code:
class NameList
{
private:
  const int SIZE; // Size of the array
  string* mp_list; //points to the start of the array
...

And then there's assignment operator
NameList NameList::operator = (const NameList &otherList)
{
  SIZE = otherList.SIZE; // DOES NOT WORK

  delete[] mp_list;
  mp_list = new string[SIZE]; // Creating an array with a new size

  *mp_list = *otherList.mp_list; // copying content of the other array
}


This will not work since you can't change const. But it's bad if I don't change the SIZE variable. Is there a way to create an assignment operator with const variable? Or is it ok if the size of the array is not const or it's bad programming? What would you do?
AnswerRe: Using assignment operator = for a class with const memeber variables? Pin
CPallini7-Oct-18 20:36
mveCPallini7-Oct-18 20:36 
AnswerRe: Using assignment operator = for a class with const memeber variables? Pin
Richard MacCutchan7-Oct-18 21:47
mveRichard MacCutchan7-Oct-18 21:47 
AnswerRe: Using assignment operator = for a class with const memeber variables? Pin
«_Superman_»9-Oct-18 1:51
professional«_Superman_»9-Oct-18 1:51 
QuestionAccess a pointer value changed in another class Pin
meerokh5-Oct-18 6:30
meerokh5-Oct-18 6:30 
AnswerRe: Access a pointer value changed in another class Pin
Victor Nijegorodov5-Oct-18 7:51
Victor Nijegorodov5-Oct-18 7:51 
GeneralRe: Access a pointer value changed in another class Pin
meerokh5-Oct-18 8:10
meerokh5-Oct-18 8:10 
GeneralRe: Access a pointer value changed in another class Pin
Victor Nijegorodov5-Oct-18 8:37
Victor Nijegorodov5-Oct-18 8:37 
AnswerRe: Access a pointer value changed in another class Pin
CPallini5-Oct-18 11:28
mveCPallini5-Oct-18 11:28 
GeneralMessage Closed Pin
9-Oct-18 23:31
Henry John9-Oct-18 23:31 
QuestionRe: Access a pointer value changed in another class Pin
CPallini9-Oct-18 23:58
mveCPallini9-Oct-18 23:58 
QuestionConversion from C to C#, Need C# Method Signature Pin
akvbsoft4-Oct-18 8:50
akvbsoft4-Oct-18 8:50 
AnswerRe: Conversion from C to C#, Need C# Method Signature Pin
vcbeaut4-Oct-18 16:48
vcbeaut4-Oct-18 16:48 
AnswerRe: Conversion from C to C#, Need C# Method Signature Pin
Victor Nijegorodov4-Oct-18 21:43
Victor Nijegorodov4-Oct-18 21:43 
QuestionMake screen bigger Pin
Member 139824711-Oct-18 8:37
Member 139824711-Oct-18 8:37 
AnswerRe: Make screen bigger Pin
Member 139824711-Oct-18 8:55
Member 139824711-Oct-18 8:55 
GeneralRe: Make screen bigger Pin
Maximilien3-Oct-18 4:28
Maximilien3-Oct-18 4:28 
GeneralRe: Make screen bigger Pin
enhzflep3-Oct-18 7:38
enhzflep3-Oct-18 7:38 

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.