Friday 15 April 2011

c++ - How to initialize linked list whose node is matrix? -



c++ - How to initialize linked list whose node is matrix? -

in c++, can initialize linked list nodes matrix? can utilize std::list< double[2][2]> mylist, means every node in linked list 2*2 matrix?

if cannot initialize this, how can accomplish it?

you need wrap matrix in struct or class, e.g.

#include <list> struct d { double a[2][2]; }; int main() { std::list<d> mylist; d d = { 1.0, 2.0, 3.0, 4.0 }; mylist.push_back(d); }

live demo

c++ linked-list

No comments:

Post a Comment