Calling Cdocument function in Cview function

This is a discussion on Calling Cdocument function in Cview function within the Windows Programming forums, part of the Platform Specific Boards category; So i have this in my Cdocument header Code: char* GetbyteBuffer(void); char* byteptr; then i have this as the definition ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    55

    Calling Cdocument function in Cview function

    So i have this in my Cdocument header
    Code:
    char* GetbyteBuffer(void);
    char* byteptr;
    then i have this as the definition

    Code:
    char* CMyDoc::GetbyteBuffer(void)
    {
    	return byteptr;
    }
    In my ondraw fuction in the view class i have this

    Code:
    char* m = CDocument::GetbyteBuffer();
    it doesn't compile with the last line.. i can't call it in my view class... it is public.. so i dont' know what's going on.. thanks

  2. #2
    Registered User
    Join Date
    Sep 2003
    Posts
    55
    Okay.. the error i get is..

    "GetbyteBuffer" is not a member of Cdocument.. but it is!!!

  3. #3
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    To use a member function of a class, you must first instantiate it, declare it, you know

    Code:
    	Cdocument ourDocument;
    	ourDocument.GetbyteBuffer();
    [exception to this: static member functions. If you meant Getbytebuffer to be static, it cannot access non-static class fields, but you seem to want to return some class field buffer, so forget all this static bizness and instantiate a Cdocument object before using it!]

  4. #4
    Registered User
    Join Date
    Sep 2003
    Posts
    55
    I see i see.. I'll try that out...

    latet though.. gotta go to school

  5. #5
    Registered User
    Join Date
    Sep 2003
    Posts
    55
    Sorry just to clarify..

    so you're saying i should create a dummy object from the document class.. and the just call my function.. and get it to return what i want to a variable in my view class??

    thanks..

  6. #6
    Registered User
    Join Date
    Sep 2003
    Posts
    55
    Okay, i tried what you suggested and it's not working..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  3. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 04:06 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  5. Calling a user-defined function in C++
    By brianptodd in forum C++ Programming
    Replies: 3
    Last Post: 10-08-2002, 01:09 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21