|
-
Feb 3rd, 2003, 10:32 AM
#1
Thread Starter
Addicted Member
passing pointers
i have a string pointer declared in a class like this:
class Track {
public:
void Init();
private:
int TrackNum;
string *LlamaNames;
};
void Track::Init() {
LoadInfo(LlamaNames,TrackNum);
}
void LoadInfo(string *Names, int Num) {
switch (Num) {
case 1:
Names = new string[3];
Names[0] = "blah"......
break;
case 2:
Names = new string[4];
Names[0] = "blah1"......
break;
}
}
Basically i want to call Init() on a track after changing its track number. Based on that tracknumber, it will load different information into the class. And thus, i want to dimension a spot in memory outside of the class. As my understanding, Names (local) is pointing to the same spot as the member pointer LlamaNames, so shouldn't dimensioning Names dimension the same memory spot that LlamaNames points to? When ever i run it it crashes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|