C++ Pointer to Pointer [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Im trying to do a pointer to pointer to a dynamic array that his elements will be a pointer to "figurasGeom"
How can I do it? I started with the pointer to pointer but Im not sure if that is ok..
figuraGeom ** lista;
Is there another way to make a dynamic array without using "vector"?
I have something like this but I dont know how to implement it
figuraGeom* vectr [];
Thank you in advance!

Based on your description, you left the vector part out, so you would need something like this:
vector<figuraGeom*> **lista;
But this is a really weird data representation, at least in C++. You should start working more with higher-level containers and/or smart pointers in C++.

Related

Is there a way to convert an array of float** to Objective C and displaying those values [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Currently working on a project that requires a iOS Wrapper and I need to translate data that is coming from C++ that is a float array (float*) to an array in Objective C (Assuming NSArray). I'll also need to display the values as well but I'm honestly confused in how to go about that, I tried memcpy but it doesn't seem to work, I think its because there is no way to access NSArray objects within memcpy.
C++ float* and Objective-C float* are the same. Or write code in Objective-C++ if you have a C++ std::vector.
NSArray can only hold Objective-C objects, not float. But it would be a lot better to first find someone who knows Objrctive-C, possibly Swift, and knows what is actually needed.

What is the difference between using pointer vector or non pointer vector? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
private:
vector<float*> m_values;
vector<float> *m_index;
vector<float*> *m_rowptr;
What would be the best way to save a large data structure, using vectors?
The way to store a large quantity of floats is:
vector<float> m_index;
The vector manages the block of floats for you.
Making a pointer to the vector is pointless (hah!).
Making a vector of pointers is (usually*) not correct for your task, and it introduces a host of performance problems.
Making both things a pointer combines the two problems.
* Depending what you mean by "index", this may be one of those times. If you want a vector of "pointers to float", then make that thing.

Finding indexed data-structure like `std::vector` (not array) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am looking for a data structure which can store values with index and also can be resized like a std::vector (but should be indexed so I can access it easily) is there any C++ standard library implementation of my problem?
What I am looking for is an array-type DS from which I can remove elements.
You can use std::deque which is also indexed sequence container like std::vector. It provids also std::deque::resize member function.
However, your requirement should be much more specific to suggest std::deque at first place than std::vector

How can an immutable string be implemented in C++? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
All my attempts so far have failed.Basically when I return a copy of the internal char array of the string, that copy has to be released, but I don't know how to release it.Wrapping it in a smart pointer doesn't work out, since it's destructor gets called immediately after I return it.Must I implement something like a garbage collector just for the immutable string?
const std::string will be fine.

how to create custom byte level datatype? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'd like to know how to create my own byte level datatype (like int, short, long, etc.). I know some will ask "Why!!? this is crazy!!" let's say I don't wanna use classes or structs. And I wanna know how to create that kind of datatype for C/C++ even if I have to use asm code for that (which I guess I'll have to use). Or is there a book that could help?
Can anyone please help? thank you.
If you exclude all the methods C and C++ give you to create new types then you can't create new types.
It's simple with a class:
Make a class that has some sort of storage. If you insist on doing everything manually then just make this an array of bytes. Overload all the operators you want to support.
class my_datatype
{
public:
my_datatype();
// overload operators
private:
uint8_t[sizeof_my_datatype] data;
};
Other than classes and structs, the only way to "make" a new datatype in C and C++ is a typedef. That's nothing more than an alias, though.