Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 12-03-2006, 08:52 PM   #1 (permalink)
albtross
Recruit
 
Join Date: Nov 2006
Posts: 9
albtross is on a distinguished road
reference question! quick question, pls help

i have troubles understanding what is the difference between nonlocal reference and global reference, because by definition, they are both saying reference is accessible to local process but it's not created on entry.
so anyone can clarify it with examples plz help.
albtross is offline   Reply With Quote
Old 12-04-2006, 07:57 PM   #2 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
All global references are nonlocal but not all nonlocal references are global references.
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 12-05-2006, 12:06 PM   #3 (permalink)
albtross
Recruit
 
Join Date: Nov 2006
Posts: 9
albtross is on a distinguished road
Quote:
Originally Posted by teknomage1 View Post
All global references are nonlocal but not all nonlocal references are global references.
ya, now i remember, thx. nonlocal is a bigger scope, like if we declare a variable in main, then we have a block structure code, and it can use that variable, however, it's neither local nor global to the blocks.
albtross is offline   Reply With Quote
Old 12-06-2006, 01:20 PM   #4 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Quote:
Originally Posted by albtross View Post
because by definition, they are both saying reference is accessible to local process but it's not created on entry.
Who is "they"?

This is the ISO section so here's an example within the scope of ISO C++.

Code:
#include <iostream>

using namespace std;


int main()
{
	int MyNumber = 5;
	{
		int MyNumber = MyNumber;
		MyNumber = 3;
		std::cout<<MyNumber<<endl;
	}
	std::cout<<MyNumber<<endl;

}
Output:
3
5

Quote:
ISO C++ definition: 3.3, item 2

Note: a nonlocal name remains visible up to the point of declaration of the local name that hides it.
__________________
Valmont is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
DevC++ Help clavezza Platform/API C++ 2 04-13-2006 11:19 AM
hey redhead quick question about c/c++ rogue Standard C, C++ 2 05-23-2005 01:22 AM
SDE (or anyone), quick pls. Valmont Lounge 1 03-16-2005 09:06 AM
Quick question on <table>'s Redline HTML, XML, Javascript, AJAX 3 10-30-2004 08:12 PM
Quick anti-aliasing question ntws01 Java 2 03-20-2003 06:00 PM


All times are GMT -8. The time now is 07:36 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting