its me again
thanx to all people who replied my previous q..
lol ive another question
how i can return a pointer to an array of structures?
for example in this function
struct* StoreData(int job, int arrival, int service, int leaving)
struct data mydata ;
i donno i always got an error considering the returned value
thanx alot again
You can't return pointers to local data. Local variables go out of scope when the function exits, so your pointer is no longer valid.
Ways out are
1. Pass the array as a parameter to the function
2. Make the local array static
3. Allocate a dynamic array and return that
about My Last post
Thanx for those who replied..whether they were sarcastic
or not..im just a beginner of C++..i am not a shame to ask anything..even if it was a stupid question..i guess
about this code ive written ..i can read it as i could write it;however, it gives me a compiling error this is why i asked what's wrong wiz it ..so simple!!
--------------------Configuration: trial1 - Win32 Debug--------------------
E:\ass#210\ass6tr1\trial1.cpp(389) : error C2440: 'return' : cannot convert from 'struct Data *' to 'struct $S9 *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
trial1.exe - 1 error(s), 0 warning(s)
Your struct should be outside the function, not inside
data *StoreData(int job, int arrival, int service, int leaving)
data mydata ;