Tuesday, July 28, 2009

I have a question about c ++?

i am reading my book but it does not give examples at all...


its a c++ book...


write code so i can study it for best answer. Two questions








1. Write the statement, which declares a pointer to an integer data-type. Name the pointer 'd_address'.





(what the hell is a pointer) how?





2. Write a function definition header named 'return_address' which returns a pointer to a dynamically created array of integers. The function should receive an integer in a variable named 'numbers'.


Note: do not write the code for the function block, only the header!


(no idea)

I have a question about c ++?
I will referr you to some sources that may help.


I hated C++ and have done a brain dump on that entire language. ;o)
Reply:pointer holds the memory location adress of the variable.





1:





int * d_address;


// The star declares the variable as a pointer





2:


int* return_address( int numbers )


//int* is the type of a pointer on int
Reply:A pointer holds the address in memory of the location of the variable. So in #1:


int * d_address; // The star declares the variable as a pointer





#2. int return_address( int numbers )





The first int is the type that gets returned by the function. The int numbers is the passed in variable.


No comments:

Post a Comment