Hi,

I am currently writing a C++ API for Unigraphics(CAD Program) as part of my final year uinversity project.

In the example programs im modifying, there is alot of use of '*' and '&', in the context:

When defining variables:

char *feature_select = "Please Select Features";
void *filter = NULL;
int *count = NULL;
tag_t **feature_tags;

sorry theres more to it, accidently hit post...

For '&':

UF_CALL( UF_UI_select_feature( feature_select, filter, count, &feature_tags, &response));

If any would could help me by describing to me what the '*' and '&' are and do, it would be greatly appreciated...

Thanks,

Tom

http://www.daniweb.com/tutorials/tutorial10184.html
http://www.daniweb.com/tutorials/tutorial12655.html
http://www.daniweb.com/tutorials/tutorial18274.html

An * means that we are talking about a pointer to a variable. For example, int x is a variable x which contains an integer. int* x is a variable x which contains the memory location of an integer (a pointer to an integer). When we use int& in the list of parameters for a function, we are passing by reference (as opposed to by value). In other words, we're passing the memory location of where an integer can be found instead of a copy of the value of the integer - any changes made within the function will hold when the function completes.

Thankyou very much, i understand it better now. One more thing what is different about a double *? As used in:

tag_t **feature_tags

** is mean pointers to pointers

example

#include <iostream>

using namespace std;

int main()
{
	char c = 'L';
	char *cp = &c;
	char **cpp = &cp;

	cout << "c = " << c << endl;
	cout << "cp = " << *cp << endl;
	cout << "cpp = " << **cpp << endl;
	system("Pause");
}
This article has been dead for over six months. Start a new discussion instead.