So, i declare an array and then just return a pointer to the array and use a counter to display/use the data in the array.
how will te code look like ? something like return *pi;??
So, i declare an array and then just return a pointer to the array and use a counter to display/use the data in the array.
how will te code look like ? something like return *pi;??
`Who are YOU?' said the Caterpillar.
This was not an encouraging opening for a conversation. Alice replied, rather shyly, `I--I hardly know, sir, just at present-- at least I know who I WAS when I got up this morning, but I think I must have been changed several times since then.' - Lewis Caroll's Alice in Wonderland.
If you use grumpy's code.. itd be like this (and of course you could pass parameters to aFunction instead):
Looking at that makes me cry.. it looks like such an inefficient method, but then again its late and I've never tried anything like that before.. I'll see in the morning if I can come up with any better ideas for passing lists, for own benefit.Code:#include <iostream> using namespace std; struct theStruct { int a,b,c,d; }; theStruct aFunction(); int main() { theStruct anObject; anObject = aFunction(); cout << anObject.a << endl; cout << anObject.b << endl; cout << anObject.c << endl; cin.get(); } theStruct aFunction() { theStruct theObject; theObject.a = 1; theObject.b = 2; theObject.c = 3; theObject.d = 4; return theObject; }
Looking at it it looks like I should return a pointer and make it = new theObject, but I cant think of how I'd recieve it.. its too late, hope it gives you something to work with.
Last edited by Dae; 06-22-2005 at 02:59 AM.
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101
I actually understand it! Thanks
`Who are YOU?' said the Caterpillar.
This was not an encouraging opening for a conversation. Alice replied, rather shyly, `I--I hardly know, sir, just at present-- at least I know who I WAS when I got up this morning, but I think I must have been changed several times since then.' - Lewis Caroll's Alice in Wonderland.