I think my concept has a bug that I cannot handle the pointer array passing throughout function very well. Take the following code as an example:
books(char auth, char tit) //constructor2
cout << "Destructor: " << author << endl << endl;
void set_author(char s);
void set_title(char s);
void* pointer(const char* a); //Am I right or wrong?
void* pointer1(const char* t);
void books::set_author(char s)
void books::set_title(char s)
void* books:ointer(const char* a) // Am I right or wrong?
return a; //How should I set the return value?
void* books:ointer1(const char* t)
cout << author << " , " << title << endl << endl;
int main(int argc, char* argv)
books bk1, bk2, bk3("Paul", "Story book");
bk1.set_author("Raymond"); //through base class public function to access the data members
bk1.set_title("Eye on HK");
bk2.display(); //constructor 1 (call constructor 1)
bk3.display(); //constructor 2 (call constructor 2)
books *bk4 = new books("Peter", "Maths"); //Dynamic pointer and allocate a memory space
/*char x = "ABC";
books *bk5;*/ // Don't know how to pass char array "ABC" to the void pointer function above to set the author name???
Also, is there no such thing: reference array? e.g. &x.
If so, reference will only deal with single int, char or string but not array??
There is pass by value - the local variables in main will not change.
pass by reference - the local variables in main will change.
How about pointer? Is it a kind of pass by reference? I messed up these stuff. Anyone could give me an example like the above how to pass pointer between main and function? and when should I use it?
Thank you very much.