problem with function.....
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: problem with function.....

  1. #1
    Join Date
    Apr 2009
    Posts
    3

    problem with function.....

    where have I gone wrong.....just a beginer here...something is wrong with my remove function.

    struct TeleType{
    string name;
    string phoneNo;
    TeleType *ptr;
    };
    void remove(TeleType *);
    const int REC = 5;
    int main(){
    TeleType client[REC] = {{ "Summer One", "(876)876-8765", &client[1] },
    { "Joe Smoe", "(726)245-8954", &client[2] },
    { "Mighty Moe", "(927)569-2592", &client[3] },
    { "Slow Joe", "(812)294-0283", &client[4] },
    { "Winter Two", "(846)764-3467", &client[0] }};
    for(int i = 0; i < REC; i++)
    cout << setw(20) << left << client[i].name
    << setw(10) << client[i].phoneNo << " "
    << setw(10) << client[i].ptr
    << endl;
    cin.ignore(1);
    return 0;
    }
    void remove(TeleType *ptr)
    {
    *myPtr = client[0]; // I can't get this to delete client[1](Joe Smoe) yet keep
    myPtr.ptr = &client[2]; // the loop going in the cout statement.
    delete client[1];
    return;
    }

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,888

    Re: problem with function.....

    There's a lot wrong there......

    1) You posted code without code tags.
    2) You're trying to use "delete" in the remove function, when (as far as I can tell) the linked list is currently being allocated on the stack. Which is itself pretty strange.
    3) You have indexes hard-coded in the remove function for some mysterious reason.
    4) You have not given a sufficient explanation of your goal, difficulty, and specific problem encountered.

  3. #3
    Join Date
    Apr 2009
    Posts
    3

    Re: problem with function.....

    sorry about that...I've been playing with this for the last week and am getting frustated. I have changed my remove function several times, some with less errors this is what I have now.

    error C2065: 'myPtr' : undeclared identifier
    (39) : error C2065: 'client' : undeclared identifier
    (40) : error C2065: 'myPtr' : undeclared identifier
    (40) : error C2228: left of '.ptr' must have class/struct/union
    type is ''unknown-type''
    (40) : error C2065: 'client' : undeclared identifier
    error C2065: 'client' : undeclared identifier

  4. #4
    Join Date
    Apr 2009
    Posts
    3

    Re: problem with function.....

    assignment calls for me to remove one of the structures from the linked list...catch is that I need to take the value of the ptr in the removed structure and replace it with the value of the preceding structure. I believe I would have to delete that structure after doing this.

  5. #5
    Join Date
    Feb 2009
    Posts
    42

    Re: problem with function.....

    error C2065: 'myPtr' : undeclared identifier
    (39) : error C2065: 'client' : undeclared identifier
    (40) : error C2065: 'myPtr' : undeclared identifier
    (40) : error C2228: left of '.ptr' must have class/struct/union
    type is ''unknown-type''
    (40) : error C2065: 'client' : undeclared identifier
    error C2065: 'client' : undeclared identifier

    Errors talk to you. Listen.

    (39) : error C2065: 'client' : undeclared identifier - you didn't declared variable client
    (40) : error C2065: 'myPtr' : undeclared identifier - you didn't declared variable myPtr
    (40) : error C2228: left of '.ptr' must have class/struct/union - you have used pointer. Use -> instead of . ( or variable isn't declared so linker cannot resolve the member of variable )
    (40) : error C2065: 'client' : undeclared identifier - you didn't declared variable client

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center