From C to C++ Pointer
-
I have C background but I need something like pointer so store two double variable data. Could anyone show me how or post some tutorial website here? Thanks.
One way:
double d1 = 5.1;
double *p1 = &d1;Another:
double *p1 = new double;
*p1 = 1.8;
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
One way:
double d1 = 5.1;
double *p1 = &d1;Another:
double *p1 = new double;
*p1 = 1.8;
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
I have C background but I need something like pointer so store two double variable data. Could anyone show me how or post some tutorial website here? Thanks.
store where and how ?
double* d1;
double* d2;d1 = new double;
*d1 = 0.4;d2 = new double;
*d2 = 0.3;
Maximilien Lincourt Your Head A Splode - Strong Bad
-
jw81 wrote: any easier class in MFC? What I provided was not easy? Are you sure that you understand what you are asking? A pointer in C is the same pointer in C++. Encapsulating a simple pointer into a C++ class is unnecessary.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
jw81 wrote: any easier class in MFC? What I provided was not easy? Are you sure that you understand what you are asking? A pointer in C is the same pointer in C++. Encapsulating a simple pointer into a C++ class is unnecessary.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
My mistake, I was thinking abt linked list. Sorry abt the confusion. Does VC++ linked list same as C? Thanks.
yes; all C constructs are C++ compatible. but I would suggest using either MFC collections or STL collections
Maximilien Lincourt Your Head A Splode - Strong Bad
-
yes; all C constructs are C++ compatible. but I would suggest using either MFC collections or STL collections
Maximilien Lincourt Your Head A Splode - Strong Bad
Thanks Maximilien, This is the actual question I am asking, could you suggest any MFC function that I can use for such case (linked list)? There are quite a lot of solution from MFC but I dont know which one is the best. If it is too difficult to show here could you post any url related to such case? Thanks.
-
Thanks Maximilien, This is the actual question I am asking, could you suggest any MFC function that I can use for such case (linked list)? There are quite a lot of solution from MFC but I dont know which one is the best. If it is too difficult to show here could you post any url related to such case? Thanks.
jw81 wrote: I can use for such case (linked list)? Look for Collection Classes in MSDN. Some of them are
- Clist
- CPtrArray
- CArray
or In STL
- std::list
- std::vector
"I Think this Will Help" Alok Gupta
visit me at http://www.thisisalok.tk