I have to admit my first post is quite inaccurate, since pointers and arrays are the same thing. In MagiusCHE's code above I noticed something else in the VB function:
public sub PassArray()
dim myarr(0) as starr
redim myarr(0).superarr(0)
myarr(0).value3=3
myarr(0).superarr(0).value1=1
myarr(0).superarr(0).value2=2
msgbox tryout(myarr(0))
end sub
The statement "redim myarr(0).superarr(0)" may declare superarr(0) as a variant in VB, not a structure, since there's no data type specified. It may be worth a try to change it to read "redim myarr(0).superarr(0) As secondarr" and see if C++ will recognize it then. I would like to recall the suggestion I made above, as the rest of MagiusCHE's code seems to be fine.
rsathish, if you're asking why I recommended that he declare 2 variables with the same name (secondarr superarr, and strarrptr* superarr), it was a mistake on my part, sorry. If you're asking what the astrisk * is, it only means the variable is a pointer of that data type, not a variable of that data type. A pointer holds a memory address and allows parts of your code to change the value in that address, rather than a copy of that value. A perfect example is passing values to a function. By default this makes a copy of the variable to pass to the function and whatever changes the function makes to the variable won't be seen after the function returns:
----------------------------------
int Example(){
int MyVar = 4;
Test(MyVar);
return MyVar;
}
void Test(int Value){
Value = 5;
return;
}
-------------------------------
The function Example() will return 4, not 5, because the function didn't actually change MyVar. It changed a copy of it. Here's an example of how to fix this with a pointer:
----------------------------------
int Example(){
int MyVar = 4;
Test(&MyVar);
return MyVar;
}
void Test(int* Value){
*Value = 5;
return;
}
-------------------------------
Now when I call Test() I pass it the "address of" MyVar, and the function now expects to handle a pointer to an integer. Now whenever Test() changes that value, it's changing the variable that the pointer points to.
Hopefully that makes sense, and if not there's a lot of tutorials on the i-net that are better than what I can come up with in just a few minutes.
Hope that helps!
~Mike
Any man willing to sacrifice liberty for security deserves neither liberty nor security.
-Ben Franklin