Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Using Class Template in Visual C++

yalcinyalcin Member Posts: 4
Hello,

I wrote template which return matrix in Window Form Application .My template is below:

[code]template
class matrix1 {
protected:

public:
T *data;

const unsigned rows, cols, size;
matrix1(unsigned r, unsigned c) : rows(r), cols(c), size(r*c) {

data = new T[size];
}
~matrix1() { delete data; }
void setValue(unsigned row, unsigned col, T value) {
data[(row*cols)+col] = value;
}
T getValue(unsigned row, unsigned col) const {
return data[(row*cols)+col];
}

};[/code]

I wrote this code in Main Project File in Windows Form Application.I defined 341*680 matrix with using this template :

[code]matrix1A(341,680);[/code]

I used function that do operation on this template and I defined it like this:

[code]void function(matrix1 &b,array< double>^ data)[/code]

And call it:

[code]function(A,temp);[/code]

(temp is one dimensinonal data array that I have to use for my programming algorithm)

For Example;When I want to print data that is located in the first row and first column.

Visual C++ recognise getvalue and setvalue function ,but couldn't print anything and gave a lot of error interested with matrix1 template

I tried this template and function on CLR Application and it worked.How could I do this On Windows Form Application?And Where should I locate template class on Windows Form Application?

Best Regards...









Sign In or Register to comment.