rhilberman
New member
- Joined
- Apr 1, 2003
- Messages
- 2
I am a beginning programer, with previous C experience. As I am picking up the ropes of C++, I am trying to venture into the realm of programming with objects. Along these lines, I am curious about using CArray or CObjarray instead of the pointer array method that I had used before. I have searched the web, and various books, to find a simple explanation of how to declare a CArray, but everyone seems to have different solutions. What is the best way to turn a statement like:
double *dummy_arr;
int sizeofarray=40;
dummy_arr = (double *) new double*[sizeofarray];
into a Carray statement?
I have seen a solution that includes:
typedef CArray <CRect, CRect&> Crectarray;
Public:
enum{nlinesperpage = 12}
enum{nMax=50}
Crectarray newarr;
crectarray.setsize(nlinesperpage, nMax);
...
The syntax questions that I have with the above statements are abundant! To start with, I am confussed by the CRect& statement (or, as is in the help files, <class TYPE, class ARG_TYPE = const TYPE& >, and I am confussed by how "public:" can be used outside of a class (perhaps the class statement is just missing)?
I am considering just sticking to my old mode of programming, but I also like challenges too much to pass up object oriented programming.!
If someone is willing to give me some pointers, Id appreciate it.
Thx,
double *dummy_arr;
int sizeofarray=40;
dummy_arr = (double *) new double*[sizeofarray];
into a Carray statement?
I have seen a solution that includes:
typedef CArray <CRect, CRect&> Crectarray;
Public:
enum{nlinesperpage = 12}
enum{nMax=50}
Crectarray newarr;
crectarray.setsize(nlinesperpage, nMax);
...
The syntax questions that I have with the above statements are abundant! To start with, I am confussed by the CRect& statement (or, as is in the help files, <class TYPE, class ARG_TYPE = const TYPE& >, and I am confussed by how "public:" can be used outside of a class (perhaps the class statement is just missing)?
I am considering just sticking to my old mode of programming, but I also like challenges too much to pass up object oriented programming.!
If someone is willing to give me some pointers, Id appreciate it.
Thx,