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

Thread: "const" problem

Threaded View

  1. #4
    Join Date
    May 2006
    Location
    Dresden, Germany
    Posts
    458

    Re: "const" problem

    Addition (since laserlight supposed a function returning a const <type> *):

    Alternative function to get the const pointer:

    Code:
    const class T* GetT(){return &g_t;};
    in main:

    Code:
    	class T* t = GetT(); // not possible => compiler error
    	const class T* t = GetT(); // possible
    	t->ConstMethod(); // possible
    	t->Method2ChangeData(); // not possible => compiler error
    With regards
    Programartist
    Last edited by ProgramArtist; June 19th, 2009 at 04:33 AM. Reason: typo ...

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured