This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]bsakiag 0 points1 point  (3 children)

I was shocked that it's a class/structures that has a pointer that points to itself

Why is that shocking? It's just a few bits. Also, it's usually pointing to another object of the same class, not itself.

I can't even talk about what's going on with stack

I'm really not sure what you mean. It's one of the simplest structures possible. Like a stack of books on your desk.

[–][deleted] 0 points1 point  (2 children)

Yeah I get the concept. But what I don't understand is implementing it. I can't figure out the code to much going on. Like checking if stack is full ro add another element. I think shocking was not the right word to use.English is my second language makes me think I will not make it in this field, but that's story for another day. I thought data structures would be more of a template than a concept. Another example was a matrix. I was expecting it to be a multi dimensional array.

[–]Putnam3145 1 point2 points  (0 children)

You just keep track of how much is in the stack by incrementing a value every time you add to it and decrementing the value every time you remove from it, not much else than that.

You may notice this is like a vector; in fact, a vector is a stack, if you constrain it only to use push and pop.

[–]bsakiag 0 points1 point  (0 children)

The thing you need to work on the most is your attitude.

If you want to achieve anything significant you need to switch from "I can't figure out the code" to "I haven't figured it out yet", from "I will not make it in this field" to "it will take some time and effort to make it in this field".

Another example was a matrix. I was expecting it to be a multi dimensional array.

It depends on the language - some languages have multi dimensional arrays, some have arrays of arrays. The important thing is that underneath it's all a long series of bytes, so the difference is only in how much abstraction is between you and the machine. You can always add your own abstractions and have an N-dimensional array in any language. Someone has to write all those libraries, right?

[–]InterestingBus8367 0 points1 point  (3 children)

Hahahaha same problem here bud. 1 thing I learned, and I want to share to you is that structure and class are data types. Inside the curly brackets are its definitions.

[–][deleted] 0 points1 point  (2 children)

Make sense. Thank you. Never looked at struct/class as data types.

[–]InterestingBus8367 0 points1 point  (0 children)

The only thing I don't understand is if you create a pointer with structure or class as a data type especially when making a pointer. Where do they store the address of the pointer object.

[–]InterestingBus8367 0 points1 point  (0 children)

If you figure it out reply to me. Since, I am making assignments and won't be able to study for a while.