Click here to Skip to main content
       

C / C++ / MFC

 
GeneralRe: Inability to edit .rc files PinmvpCPallini22-Jan-13 9:41 
AnswerRe: Inability to edit .rc files PinmemberMax_Power_Up26-Feb-13 6:02 
GeneralRe: Inability to edit .rc files PinmemberAnthony Appleyard26-Feb-13 6:39 
QuestionUser privileges stopping a program from rename(,)'ing files [modified] PinmemberAnthony Appleyard20-Jan-13 18:51 
AnswerRe: User privileges stopping a program from rename(,)'ing files PinmemberSuper Lloyd20-Jan-13 19:52 
GeneralBUG FOUND [modified] PinmemberAnthony Appleyard21-Jan-13 0:03 
GeneralRe: BUG FOUND PinmemberSuper Lloyd21-Jan-13 0:57 
QuestionA pointer reference as l-value [modified] PinmemberGeorge Nistor20-Jan-13 2:07 
hi
Here is my problem:
I don't understand why in the following code the second line is error and the third is ok.
In the first case where the error is I will get a copy and in the second reference to the pointer.
Why the reference is considered l-value?
 
// Node class
class Node {
private:
	int key;
	Node* left;
	Node* right;
 
	typedef Node* Link;
public:
	Node() { key=-1; left=NULL; right=NULL;};
	void setKey(int aKey) { key = aKey; };
	int Key() { return key; };
	Link Left() { return left; };
	Link& Right() { return right; };
};
 
int _tmain(int argc, _TCHAR* argv[])
{
	Node *p= new Node();
	p->Left()= new Node(); //error : error C2106: '=' : left operand must be l-value
	
	p->Right()= new Node(); //this one is lvalue
	
	return 0;
}


modified 20-Jan-13 8:56am.

AnswerRe: A pointer reference as l-value PinmemberMaximilien20-Jan-13 3:18 
AnswerRe: A pointer reference as l-value PinmvpRichard MacCutchan20-Jan-13 3:56 
GeneralRe: A pointer reference as l-value PinmemberGeorge Nistor20-Jan-13 4:02 
GeneralRe: A pointer reference as l-value PinmvpRichard MacCutchan20-Jan-13 4:11 
GeneralRe: A pointer reference as l-value PinmemberFreak3021-Jan-13 4:43 
GeneralRe: A pointer reference as l-value [modified] PinmemberGeorge Nistor21-Jan-13 5:37 
GeneralRe: A pointer reference as l-value PinmemberFreak3021-Jan-13 22:08 
QuestionThe 'rename' function gives errno == -1 PinmemberAnthony Appleyard20-Jan-13 1:12 
AnswerRe: The 'rename' function gives errno == -1 Pinmemberpasztorpisti20-Jan-13 1:26 
GeneralRe: The 'rename' function gives errno == -1 PinmemberAnthony Appleyard20-Jan-13 3:01 
AnswerRe: The 'rename' function gives errno == -1 PinmvpRichard MacCutchan20-Jan-13 3:50 
GeneralRe: The 'rename' function gives errno == -1 PinmemberAnthony Appleyard20-Jan-13 4:32 
GeneralRe: The 'rename' function gives errno == -1 PinmvpRichard MacCutchan20-Jan-13 4:37 
GeneralRe: The 'rename' function gives errno == -1 PinmemberAnthony Appleyard20-Jan-13 5:02 
GeneralRe: The 'rename' function gives errno == -1 PinmvpRichard MacCutchan20-Jan-13 5:04 
GeneralRe: The 'rename' function gives errno == -1 [modified] PinmemberAnthony Appleyard20-Jan-13 5:11 
GeneralRe: The 'rename' function gives errno == -1 PinmvpRichard MacCutchan20-Jan-13 5:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web02 | 2.8.140916.1 | Last Updated 18 Sep 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid