C++ separate definition and constructor of object -


hello experts , pardon me rather stupid question. trying use 4heap priority queue of professor sanders, available at:

http://www.mpi-inf.mpg.de/~sanders/programs/spq/heap4.h

inside function can do:

heap4<int, int> myheap(mymax, -mymax, 10000); 

the problem is, want separate definition of myheap , initialization inside struct, like:

struct mystruct{ heap4<int, int> myheap;  void myinit(){     myheap=.... }  }; 

since want avoid pass myheap reference other functions using inside same struct. possible?

although should initialize myheap in constructor initialization list, how can assign value inside function:

myheap = heap4<int, int>(mymax, -mymax, 10000); 

edit since seems heap4 not have default constructor, must initialize in constructor initialization list:

struct mystruct {   heap4<int, int> myheap;   mystruct() : myheap(mymax, -mymax, 10000) {} }; 

Comments