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

Threaded View

  1. #4
    Join Date
    Jul 2019
    Posts
    1

    Re: C++ Windows forms with .cpp

    Hi; I had the same problem and your solution almost worked. But I need to pass and return a 2D array (matrix) to a function in such a situation and have problem with returning matrix! Could you please guide me about that?

    I have in MyForm.h
    ________________

    Code:
    .
    .
    .
    #include"GlobFcn.h"
    .
    .
    .
    private: System::Void Analyze_Click(System::Object^ sender, System::EventArgs^ e) {
    ...
    int Max_data = 0
    std::vector<std::vector<double>>  mat_data0(size_r, std::vector<double>(size_c));
    std::vector<std::vector<double>>  mat_data(size_r, std::vector<double>(size_c));
    
    ... 
    (calculating new values for Max_data and  mat_data0)
    ...
    mat_data=matNormalize(mat_data0,Max_data); //matNormalize is my function..........here I have "no instance of function template "matNormalize" matches the argument list" massage!
    ________
    Also, I have MyForm.cpp include:

    Code:
    #include "MyForm.h"
    #include"GlobFcn.h"
    ...
    
    template <size_t row_size, size_t clmn_size>
    float mat_Normalize(double (X)[row_size][clmn_size], int Max_data) {
    	//std::vector<std::vector<double>>  mat_data;
    	for (int r = 0; r < row_size; ++r) {
    		for (int c = 0; c < clmn_size; ++c) {
    			mat_data[r][c] =X[r][c]/ Max_data;
    			//cout << mat_data[r][c] << endl;
    		}
    	}
    	return mat_data;
    }
    _____________

    And GlobFcn.h as:

    Code:
    #pragma once
    template <size_t row_size, size_t clmn_size>
    float** matNormalize(double(X)[row_size][clmn_size], int Max_data);
    Could you please help me to solve the problem!
    Last edited by 2kaud; July 25th, 2019 at 11:17 AM. Reason: Added code tags

Tags for this Thread

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