Click here to Skip to main content
15,889,266 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: point reference VS value Pin
Stuart Dootson19-Apr-09 3:52
professionalStuart Dootson19-Apr-09 3:52 
GeneralRe: point reference VS value Pin
Luc Pattyn19-Apr-09 4:05
sitebuilderLuc Pattyn19-Apr-09 4:05 
GeneralRe: point reference VS value Pin
Stuart Dootson19-Apr-09 4:24
professionalStuart Dootson19-Apr-09 4:24 
GeneralRe: point reference VS value Pin
Luc Pattyn19-Apr-09 4:37
sitebuilderLuc Pattyn19-Apr-09 4:37 
GeneralRe: point reference VS value Pin
Stuart Dootson19-Apr-09 4:56
professionalStuart Dootson19-Apr-09 4:56 
GeneralRe: point reference VS value Pin
Luc Pattyn19-Apr-09 5:00
sitebuilderLuc Pattyn19-Apr-09 5:00 
GeneralRe: point reference VS value Pin
Stuart Dootson19-Apr-09 5:04
professionalStuart Dootson19-Apr-09 5:04 
GeneralRe: point reference VS value Pin
sharion19-Apr-09 5:25
sharion19-Apr-09 5:25 
You are so modest. Big Grin | :-D

According to your explanation, parameters passed to function is essential value, whatever the type of object.As for point type, address of the point is actually passed.So as to these two points, we can say that p is a copy of str,which is their only relationship. This viewpoint seems to resolve my puzzle.

Another example,
void GetMemory(char* p)
	{
		if(p != NULL)
		{
			delete []p;
			p = NULL;
		}
		if(p == NULL)
		{
			p =  new char[1000];
			*(p+10) = 'a';
		}
	}
int main()
{
char* str = NULL;
str = new char[100];
GetMemory(str);
/* */
}


Above code snippet indicates that before and after GetMemory(str);point str is being revised.I have no idea why such happens.

Much appreciate for your guys' kindness.
GeneralRe: point reference VS value Pin
Stuart Dootson19-Apr-09 7:15
professionalStuart Dootson19-Apr-09 7:15 
GeneralRe: point reference VS value Pin
sharion20-Apr-09 18:30
sharion20-Apr-09 18:30 
GeneralRe: point reference VS value Pin
Stuart Dootson20-Apr-09 19:40
professionalStuart Dootson20-Apr-09 19:40 
GeneralRe: point reference VS value Pin
sharion21-Apr-09 18:05
sharion21-Apr-09 18:05 
GeneralRe: point reference VS value Pin
Stuart Dootson21-Apr-09 21:39
professionalStuart Dootson21-Apr-09 21:39 
GeneralRe: point reference VS value Pin
sharion22-Apr-09 16:00
sharion22-Apr-09 16:00 
QuestionProblem with headers in VS 2008 [modified] Pin
mass8518-Apr-09 10:07
mass8518-Apr-09 10:07 
AnswerRe: Problem with headers in VS 2008 Pin
Luc Pattyn18-Apr-09 10:33
sitebuilderLuc Pattyn18-Apr-09 10:33 
GeneralRe: Problem with headers in VS 2008 Pin
mass8518-Apr-09 11:08
mass8518-Apr-09 11:08 
GeneralRe: Problem with headers in VS 2008 Pin
Stuart Dootson18-Apr-09 11:36
professionalStuart Dootson18-Apr-09 11:36 
GeneralRe: Problem with headers in VS 2008 Pin
mass8518-Apr-09 11:45
mass8518-Apr-09 11:45 
GeneralRe: Problem with headers in VS 2008 Pin
Stuart Dootson18-Apr-09 11:49
professionalStuart Dootson18-Apr-09 11:49 
GeneralRe: Problem with headers in VS 2008 Pin
Luc Pattyn18-Apr-09 11:57
sitebuilderLuc Pattyn18-Apr-09 11:57 
GeneralRe: Problem with headers in VS 2008 Pin
mass8518-Apr-09 12:00
mass8518-Apr-09 12:00 
Question[Message Deleted] Pin
marcusab18-Apr-09 9:16
marcusab18-Apr-09 9:16 
AnswerRe: How to copy/convert System::Object^(unsigned char) to local variable Pin
CPallini18-Apr-09 9:54
mveCPallini18-Apr-09 9:54 
Question880129 - class of matrix of complex numbers Pin
ilostmyid218-Apr-09 9:15
professionalilostmyid218-Apr-09 9:15 

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.