|
Stephen Hewitt wrote: No you wont. They'll be inherited.
Yes but you won't have a const CStr& operator=(LPCTSTR); so ...
CStr t;
t = _T("hello world");
will not compile.
led mike
|
|
|
|
|
CString doesn't have a virtual destructor, so you need to be very careful about this.
Also, since Microsoft used poor design with CString, many of the operators are member functions, which means the left hand side of the operator cannot be implicitly casted to a CString object. You can call the parent operator, but the syntax is not very pretty. I would recommend not deriving from CString and simply creating methods to operate on one (depending on what you are trying to do).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hi fellows
I have a single question. I have a float array that have 6 elements all of them initialized with values. I need to find out the size of this array. Let's called my float array of theArray. I use this commom formula: sizeof(theArray)/sizeof(theArray[0]).
My results are strange, because it returns 1. I use this code to see the values:
<br />
char cTemp[50];<br />
sprintf(cTemp, "%d %d %d", sizeof(dVertexes), sizeof(dVertexes[0]), sizeof(dVertexes)/sizeof(dVertexes[0]));<br />
MessageBox(NULL, cTemp, "", MB_OK);<br />
In the first and in the second values it returns "4", and in the third value it returns "1".
Why it returns 1? Did this operation returns the correct size of array(in my case "6")?
thanks for the support
|
|
|
|
|
Alex Cutovoi wrote: Why it returns 1?
4/4 = 1
4 = size of a pointer
is dVertexes allocated dynamically ? if so, you can't use that sizeof trick to get its size.
-c
|
|
|
|
|
my array is declared as following:
<br />
float fVertexes[6];<br />
I'm inserting this values;
<br />
fVertexes[0] = 1.0;<br />
fVertexes[1] = 0.0;<br />
fVertexes[2] = -1.0;<br />
fVertexes[3] = 1.0;<br />
fVertexes[4] = -1.0;<br />
fVertexes[5] = -1.0;<br />
I'm passing this guy to a function, like this:
<br />
primitive.Shape(GL_TRIANGLES, fVertexes, 1,1,1);<br />
Again, why it returns 1 if I don't create this guy dynamically?
|
|
|
|
|
That is an example of the decay I mentioned in my post - when you pass the array, it becomes a pointer in the called function.
The function that has the pointer has no "internal" or automatic way of knowing how much the data points to. That is why whenever you pass an array of data to a function, you usually have to tell the function how much valid data is in the array (or have a special element in the array to indicate the end of valid data).
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi,
Just modify Shape function by adding INT nCount after pointer to array of floats. Then in Shape function, calculate array size as nCount*sizeof(float) . nCount should specify the size of the array.
Regards
|
|
|
|
|
I made this:
I've passed the size of the array(like you've said) and divided by float[0] and works fine
|
|
|
|
|
I made some modifications and works fine. Thanks for the support
|
|
|
|
|
The math is working: 4/4=1.
The problem looks like dVertexes is not a true array. It is an atomic type (double ) or a pointer.
Note that using sizeof(...) in this way does not work correctly with pointers to arrays, even if they are pointers that have decayed from a true array.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
ok, so how can I discover the array size? I don't want to use vectors....
|
|
|
|
|
You have to pass the size to the called function to let it know how much valid data exists.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
I've made this:
primitive.Shape(GL_TRIANGLES, fVertexes, sizeof(fVertexes), 0,1,1);
And in the function I'm divided the size of array by the size of first element in the array. Works fine, thanks for help
|
|
|
|
|
Depending on how often you are passing these arrays around and how frequently the size changes, you might want to declare a struct with the array and the size as members, then pass that to your functions.
typdef struct _double_array
{
double array[9];
int nCount;
} DOUBLE_ARRAY, *LPDOUBLE_ARRAY;
You can then pass the stuct 'DOUBLE_ARRAY' or a pointer to the struct 'LPDOUBLE_ARRAY' .
|
|
|
|
|
Thanks for the tip. It's a good idea
|
|
|
|
|
No problem. If you look into the windows api's, you will find that many of the functions are declared like this, you either have to set up a struct or you get one back. My current project calls on the need of dealing with several arrays all relating to the same info, so instead of passing all the arrays and sizes to each function, I simply pass a pointer to a struct.
|
|
|
|
|
If the array is allocated on the heap, sizeof behaves differently than it does if it was on the stack.
int i = 0;
float stackArray[5];
i = sizeof(stackArray) / sizeof(stackArray[0]);
float* heapArray = new float[5];
i = sizeof(heapArray) / sizeof(heapArray[0]);
int myFunction(float* myArray)
{
return sizeof(myArray) / sizeof(myArray[0]);
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I have an MDI application.
In these , i have a model-less dialog box with a button which when clicked opens up a child window in the background of the dialog box
How can i make the child window to appear foreground and dialog box to appear
background when the button is clicked
|
|
|
|
|
Hi,
Could you be more specific, please? You said that it is an MDI application, though is your dialog-box created as standalone window, or as MDI-Child? If your second dialog-box is created as MDI child inside MDI frame, it can't be displayed in foreground.
Regards
|
|
|
|
|
I have a dialog box on start-up of the application .
when a button is clicked on the dailog box , it pops up an MDI child window which is displayed at the background.
|
|
|
|
|
Hi,
Veeresh Hiremath wrote: pops up an MDI child window
and this is why it is displayed in the background. As long as you create it as MDI child it is supposed to be displayed below your dialog box, though in the foreground of the parent MDI frame. This is exactly how MDI works.
Also, "it pops up" is not really the case here, since MDI child windows aren't popped up, these are just MDI frame's child windows, and if you want window to be popped up, you have to obey MDI and create it as popup.
Regards
|
|
|
|
|
Thanks for the information.
|
|
|
|
|
I want to know the path of favourites of user who is logged in of system?
|
|
|
|
|
Hi
SHGetSpecialFolderLocation with CSIDL_FAVORITES
-----------
Mila
|
|
|
|
|
of course should be SHGetSpecialFolderPath and not SHGetSpecialFolderLocation
-----------
Mila
|
|
|
|