•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 456,555 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,528 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 2444 | Replies: 4
![]() |
•
•
Join Date: Aug 2004
Posts: 11
Reputation:
Rep Power: 5
Solved Threads: 0
about the second question yes you can use pointer to refrence to another pointer and this is the method used in dynamic allocation of multi dimintion aray you can write :
void a2d(int i,int j)
{
int **t =new int*[i] ;//rows
for(int k=0;k<i;k++)
t[k]=new int[j] ; //col
}
but i do not understand the first question but notice that the pointer is a refrense mean that if u pass a pointer of int to an function it does not take a copy from the int it takes a copy of the refrence to the int so if u change the int value it will be changed and u can not retain the previous value for example :
main()
{
int *i=new int ;
*i=2;
fun (i) ;
cout<<*i;
getch();
}
void fun (int *m)
{
*m=3;
}
the result of the cout will be 3 is that what u mean ?
void a2d(int i,int j)
{
int **t =new int*[i] ;//rows
for(int k=0;k<i;k++)
t[k]=new int[j] ; //col
}
but i do not understand the first question but notice that the pointer is a refrense mean that if u pass a pointer of int to an function it does not take a copy from the int it takes a copy of the refrence to the int so if u change the int value it will be changed and u can not retain the previous value for example :
main()
{
int *i=new int ;
*i=2;
fun (i) ;
cout<<*i;
getch();
}
void fun (int *m)
{
*m=3;
}
the result of the cout will be 3 is that what u mean ?
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Cant remove files:Search assitant,search extender,or Shoping wizard from my comp!!! (Viruses, Spyware and other Nasties)
- Problem with socket (C++)
- Help with 1.pointers and 2.error checking (C++)
- Pointers (see if what I've done is correct) (C++)
- Problem with Generic Pointers (C)
- Key stroke change (Visual Basic 4 / 5 / 6)
- New gal from California (Community Introductions)
Other Threads in the C++ Forum
- Previous Thread: complex arithmatic
- Next Thread: PSP Help.


Linear Mode