I'm tired, any chance of a bit of C++ help? :o

Soldato
Joined
17 Jul 2005
Posts
3,193
Hi all,

Really simple question I guess, but i'm tired... and hate programming but have an assignment in fairly soon, and although i've nearly completed it i'm trying to add a bit more functionality...

I basically want to return a vector out of a function, to the function that originally called the called function. (lol)

I've got... (this is in the function that calls the other function...)

void class4::menuenu(vector<AnotherVec> & tempVecAN)
{
disp(tempvec, chc);
}

So that passes another vector and an integer value through to;

void class4::disp(vector<AnotherVec> & tempVecAN, int chc)
{

// some ommited...

vector<vec> vec1;

vec1.push_back(vec(temp->var1, temp->var2));

}

I basically want to return vec1 that was created in the second quote, to the calling function. What do I need to do? :o a return statement? (which I can't seem to get working!!)

Any help appreciated, i've tried loads of things that I can't see why won't work :S
 
I don't normally program c++ this should work I guess,

Code:
vector<vec> class4::disp(vector<AnotherVec> & tempVecAN, int chc)
{

// some ommited...

vector<vec> vec1;

return vec1.push_back(vec(temp->var1, temp->var2));

}

Code:
void class4::menuenu(vector<AnotherVec> & tempVecAN)
{
       vector<vec> temp = disp(tempvec, chc);
}
 
Last edited:
I managed to sort it by taking another approach (not the one I prefer but it works, so :p)

Once i've finished this section, I'l try what you put just to see for the future :)

******Not that i'm doing any programming bar occasional ASP ever ever again! (hopefully)
 
Im a C/java programmer but I don't see why what I put won't work then again I have had plenty of beer tonight :p
 
aint had chance to try it yet m8, too engrossed in doing other stuff :o

another question... i'm inputting data to a struct, and a vector simultanously from a file...

My notepad file looks like this;

RECORD1 LENGTH
RECORD2 LENGTH
CABINET1
RECORD3 LENGTH
RECORD4 LENGTH
CABINET2
RECORD5 LENGTH
RECORD6 LENGTH
CABINET3

The cabinets hold the records above them.

So when i'm inputting the data from the file, i have got a while(!file.eof) which goes through all the notepad file, and then i'm looping with a for loop to copy the first 2 lines into the struct (linked list)... and then dropping down and copying the next line into the vector.

Ideally I want this dynamic... so I can have different records inputting into different cabinets... is there any command so say if I was to put a special character into my notepad file that it would recognise this and drop out of a loop or something? E.G...

while(!file.eof)
{

while(!file.(not @ character))
{
copy to STRUCT;
}
copy to VECTOR;
}

With me?

I know i've gone about this the wrong way but this has got to be in monday and i'm only polishing up (ive accepted I suck :o).... so any advice would be appreciated :)
 
Back
Top Bottom