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

Thread: Templates

Threaded View

  1. #1
    Join Date
    Jun 2019
    Posts
    17

    Templates

    Code:
    template<int,class T>
    class MyClass {
    public:
        T buff[10];
        T TestFunction(T val) {return buff[val];}
    };
    
    int main()
    {
        struct Mystruct {
            int val1;int val2
        };
    
        Myclass<10,Mystruct> myObj;
    }
    How to assign the data to val1 and val2 and how to access and pass as argument(struct) to Testfunction?
    Last edited by 2kaud; July 4th, 2019 at 03:21 AM. Reason: Added code tags

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)