Protecting object data from member functions
From: Peter Neal (no_at_email.specified)
Date: 12/10/03
- Next message: Thomas Matthews: "Re: Homework Help"
- Previous message: Etno: "Re: Changing a variables data type"
- Next in thread: Karl Heinz Buchegger: "Re: Protecting object data from member functions"
- Reply: Karl Heinz Buchegger: "Re: Protecting object data from member functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 10 Dec 2003 16:31:58 -0000
Hi,
Consider the following (contrived!) class:
class myclass
{
public:
void display() const;
void double_X(); // x = x^2
void double_Y(); // y = y^2
private:
int X;
int Y;
};
I can protect X and Y from mutation in the display function by defining it
as const.
How would I protect Y from mutation whilst inside the double_X function and
likewise X whilst inside double_Y?
Any help gratefully received!
Pete.
- Next message: Thomas Matthews: "Re: Homework Help"
- Previous message: Etno: "Re: Changing a variables data type"
- Next in thread: Karl Heinz Buchegger: "Re: Protecting object data from member functions"
- Reply: Karl Heinz Buchegger: "Re: Protecting object data from member functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
Loading