Click here to Skip to main content
13,795,145 members

C / C++ / MFC

 
AnswerRe: Calculating decimal places - Pin
ptr_Electron16-Oct-18 4:29
memberptr_Electron16-Oct-18 4:29 
GeneralRe: Calculating decimal places - Pin
David Crow16-Oct-18 4:38
memberDavid Crow16-Oct-18 4:38 
GeneralRe: Calculating decimal places - Pin
leon de boer16-Oct-18 16:28
memberleon de boer16-Oct-18 16:28 
QuestionRe: Calculating decimal places - Pin
CPallini16-Oct-18 3:48
mvpCPallini16-Oct-18 3:48 
AnswerRe: Calculating decimal places - Pin
ptr_Electron16-Oct-18 3:55
memberptr_Electron16-Oct-18 3:55 
GeneralRe: Calculating decimal places - Pin
CPallini16-Oct-18 4:11
mvpCPallini16-Oct-18 4:11 
QuestionMessage Closed Pin
15-Oct-18 0:32
memberMember 1397497715-Oct-18 0:32 
QuestionUsing assignment operator = for a class with const memeber variables? Pin
Member 140109547-Oct-18 13:52
memberMember 140109547-Oct-18 13: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 21:36
mvpCPallini7-Oct-18 21:36 
AnswerRe: Using assignment operator = for a class with const memeber variables? Pin
Richard MacCutchan7-Oct-18 22:47
protectorRichard MacCutchan7-Oct-18 22:47 
AnswerRe: Using assignment operator = for a class with const memeber variables? Pin
«_Superman_»9-Oct-18 2:51
professional«_Superman_»9-Oct-18 2:51 
QuestionAccess a pointer value changed in another class Pin
meerokh5-Oct-18 7:30
membermeerokh5-Oct-18 7:30 
AnswerRe: Access a pointer value changed in another class Pin
Victor Nijegorodov5-Oct-18 8:51
memberVictor Nijegorodov5-Oct-18 8:51 
GeneralRe: Access a pointer value changed in another class Pin
meerokh5-Oct-18 9:10
membermeerokh5-Oct-18 9:10 
GeneralRe: Access a pointer value changed in another class Pin
Victor Nijegorodov5-Oct-18 9:37
memberVictor Nijegorodov5-Oct-18 9:37 
AnswerRe: Access a pointer value changed in another class Pin
CPallini5-Oct-18 12:28
mvpCPallini5-Oct-18 12:28 
GeneralMessage Closed Pin
10-Oct-18 0:31
memberHenry John10-Oct-18 0:31 
QuestionRe: Access a pointer value changed in another class Pin
CPallini10-Oct-18 0:58
mvpCPallini10-Oct-18 0:58 
QuestionConversion from C to C#, Need C# Method Signature Pin
akvbsoft4-Oct-18 9:50
memberakvbsoft4-Oct-18 9:50 
AnswerRe: Conversion from C to C#, Need C# Method Signature Pin
vcbeaut4-Oct-18 17:48
membervcbeaut4-Oct-18 17:48 
AnswerRe: Conversion from C to C#, Need C# Method Signature Pin
Victor Nijegorodov4-Oct-18 22:43
memberVictor Nijegorodov4-Oct-18 22:43 
QuestionMake screen bigger Pin
Member 139824711-Oct-18 9:37
memberMember 139824711-Oct-18 9:37 
AnswerRe: Make screen bigger Pin
Member 139824711-Oct-18 9:55
memberMember 139824711-Oct-18 9:55 
GeneralRe: Make screen bigger Pin
Maximilien3-Oct-18 5:28
memberMaximilien3-Oct-18 5:28 
GeneralRe: Make screen bigger Pin
enhzflep3-Oct-18 8:38
memberenhzflep3-Oct-18 8: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.


Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.181207.3 | Last Updated 11 Dec 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid