CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Jul 2002
    Posts
    788

    Why this build error undeclared identifier is related to

    Hi Guru

    I am updating my post, so my codes can be better understood; This codes is meant to demonstrate the problem i am facing, although it doesn't do anything much.

    I run VC++ 2019 with latest compiler build Visual Studio 2019 version 16.10.3; (could this be the buggg!!??)


    I get a build error at this line:
    Code:
      Diagnostic(int* pointer, std::function<QVariant(int*)> fn = [](int* pointer){return QVariant::fromValue(std::remove_pointer_t<T>(pointer)) ;})
    'T': undeclared identifier
    Does your compiler gave you such build error, i want to know., because i thought i used to be able to build this codes successfully; or have i made a mistake somewhere? How do i correct it?

    Basically my codes:
    Code:
    template<typename T>
    class Diagnostic : QObject
    {
     public:
        Diagnostic(int* pointer, std::function<QVariant(int*)> fn = [](int* pointer){return QVariant::fromValue(std::remove_pointer_t<T>(pointer)) ;})
         {
    
         
    
    
        }
    };
    
    int main(int argc, char *argv[])
    {
     int * test = new int;
           *test=5;
        Diagnostic<int*> dg(test);
        delete test;
    }
    Last edited by mce; July 9th, 2021 at 02:38 AM. Reason: To make my codes easier to understand

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