To clear up some confusion I have over pointers in the function declaration, I tried writing a program.
Here the program is:
Code:
#include <iostream>
using namespace std;
class number
{
public:
number(int initNum);
~number() {}
int GetA() const {return a;}
void SetA(int x) {a=x;}
private:
int a;
};
number::number(int initNum)
{
a=initNum;
}
number* changer(number *theNum);
int main()
{
number test(2);
cout<<test.GetA()<<"\n";
changer(&test);
cout<<test.GetA()<<"\n";
return 0;
}
number* changer(number *theNum)
{
theNum->SetA(5);
return theNum; //I realize that in this program, this line does nothing
}
Bascially, I don't fully understand this line:
number* changer(number *theNum)
^^^^^^
| | | | | |
that mostly
In my program, when I return theNum, it is sending back an memory address correct? How does the number* part modify this? Does it dereference the memory address that I send it?
Hopefully that made sense...
Thanks for any help,
--rdk