![]() ![]() Therefore the native object needs to be on the heap, so that its internals don't get changed by garbage collection. If the native type is directly within the managed type, then when managed objects get shuffled around during garbage collection, then these pointers would point to the original, now incorrect, memory. I'm thinking this might be to do with the possibilities of pointers within the native type. You can't directly contain a native type within a managed type: this is just a restriction on C++/CLI. } //this i created to store the data from the file. This is the reason i went for vector and pts solution. At first i thought it might be a wrapper class Int but then autounboxing(conversion operators) should take care of it?or is it that Point::X is qualified with property and thus is not recognized as normal int? what am i missing?. Q2) why is it that i cant use a managed code here. It gives an error c2678 : operator= is not overloaded for int!!. Q1) why is that i'm able to declare a pointer to object of native type(i guess)but not an object?įurthermore, prior to trying vector i tried the managed array as so cli::array dataPoints //and i defined it later.īut when i do this ifile > dataPoints.X The reason i need vector is because there is file that i'm reading through the ifstream and storing those values in the vector. I then have created this vector on the free store as so in the constructor of the managed class dataPoints = new std::vector(noOfElements,pts()) //which is not so attractive. In the project that i'm doing in visual C++ i have declared a std::vector inside managed class as so std::vector dataPoints //this gives error c4368 : mixed type not allowedīut this works std::vector * dataPoints //a pointer to the vector
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |