Comparing pointer objects using the pointer expression in cpp

I create a two pointer object of a class 'myclass' myclass *obj1,*obj2; can I compare these two objects using comparison operator and pointer expression i.e *obj1==*obj2 If yes, how does it happen? If not, why isn't his allowed?If yes, how does it ha

table notation vs pointer notation C

Is there any advantage to using pointer notation over array notation? I realize that there may be some special cases where pointer notation is better, but it seems to me that array notation is clearer. My professor told us that he prefers pointer not

Table pointer + integer (C ++)

I am not so familar with C++, so I want to ask, what the following code will do (I have it in an existing C++ project): 1: char* buf; 2: *buf = 0; 3: int readBytes = tcpSocket->read(buf, 10); 4: buf += readBytes; Explanation is very simple, from a TC

Pointers do not pass their value

I'm trying to solve a mystery that occured while doing the assignement. The main and entry functions works just fine, but the average one doesnt. While checking if variables constant and arraysize, it seems that they do not to pass it's values like i

Is it a good idea to use the pointer on stl vector?

In Stanley Lippman's book there is an example, when he uses vector <string> * var; why does he create a pointer to vector? Is it useful to create a pointer to vector sometimes? When should I do so?Pointers are not only useful for data on the heap, a

array, string, C pointer manipulation

This question already has an answer here: Returning an array using C 10 answers Supposedly there is a bug in this code, but it runs fine and with an output that I expect ("hello world"). Is there a problem with return str? #include <string.h&

Pointer notation vs table notation

I like pointer notation in C more than I like array notation, but just can't figure it out for some cases. I have the following code, and the body of main /*converts arguemnt to number using atoi()*/ #include <stdio.h> #include <stdlib.h> int

Declaration of a pointer to a structure

I'm confused because there seem to be two ways to initialize a pointer to a struct in the go language and they appear to me to be somewhat opposite in logic. var b *Vertex var c &Vertex{3 3} Why does one use a * and the other use a & if b and c ha

local malloc pointer locality problem

I am trying to implement a function set_it_free as shown below, but it would only play with the pointer locally, which does not do what I want, i.e. free and set to null for a pointer. Could you help me to modify my set_it_free to make it work? int s

'- & gt;' operator in C and how it is used

EDIT - updated with 2-star pointer for more relevancy Say I had a two-star pointer to a structure that also contained a pointer. typedef struct{ nodeT *ptr; }nodeT; nodeT example; nodeT *test1 = &example; nodeT *test = &test1; If I wanted the addr

Copy a table reference in VBA

Is there any way to copy an array reference in VBA (or VB6)? In VBA, arrays are value types. Assigning one array variable to another copies the entire array. I want to get two array variables to point to the same array. Is there any way to accomplish

Does derefrencing ptr while the logging error is wrong?

while going over some old code that I didnt wrote I noticed something like this(simplified) //switch case on a msg received from a queue,... //... get_function returns msgtype and ptr switch(msgtype) //... default: { MYLOGGER<< "Unknown message

The Arrow member operator in C ++

I am quite new to using C++. I have handled Java and ActionScript before, but now I want to learn this powerful language. Since C++ grants the programmer the ability to explicitly use pointers, I am quite confused over the use of the arrow member ope

In C: how to pass an array of structures as a pointer

Possible Duplicate: How to pass an array of struct using pointer in c/c++? I have an array of structures and need to pass a pointer to the array to a function. I get these compile warnings and it crashes at runtime: test.c:35:5: warning: passing argu

Adding a newly created object to a vector

I recently stated using pointers in a program and when I try the following, I am given this error. stored_points.push_back(new Point(anchor_y,anchor_x,last_direction)); error C2664: 'void std::vector<_Ty>::push_back(_Ty &&)' : cannot convert

C ++: original pointer container

I need to store references to instances of derived classes in C++. I considered using a vector of shared_ptrs to the base class (for it needs to hold different types of derived classes), however, it's important that the container holds the original p

Mutual class instances in C ++

What is the issue with this code? Here we have two files: classA.h and classB.h classA.h: #ifndef _class_a_h_ #define _class_a_h_ #include "classB.h" class B; //???? class A { public: A() { ptr_b = new B(); //???? } virtual ~A() { if(ptr_b) dele

2 quick questions about the const pointer / const reference

1) Can someone explain the following? void OnCreate(HWND hWnd, const LPCREATESTRUCT lpCreateStruct) { lpCreateStruct->x = 2; // this compiles } void OnCreate(HWND hWnd, const CREATESTRUCT * lpCreateStruct) { lpCreateStruct->x = 2; // this does not c

allocate the matrix in C

i want to allocate a matrix. is this the only option: int** mat = (int**)malloc(rows * sizeof(int*)) for (int index=0;index<row;++index) { mat[index] = (int*)malloc(col * sizeof(int)); } Well, you didn't give us a complete implementation. I assume th