Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

POINTER FUNCTIONS 1

Status
Not open for further replies.

villica

Programmer
Feb 25, 2000
332
CA
public:<br> <br>const char * GetISBN() const;<br>const char * GetTitle() const;<br>float GetPrice() const;<br><br><br>I have the above 3 function on&nbsp;&nbsp;a header file. They all return something. How do I call these function from my main program.<br>I have tried objectname.getISBN etc<br>but it does not work. Does anyone has any suggestions. <br> <p>Villica<br><a href=mailto:villica67@hotmail.com>villica67@hotmail.com</a><br><a href= > </a><br>
 
um, hmm well a function pointer has to pointer to a Real function to start with, a pointer does nothing more than point<br>thus having (void)*Myfunc(int parameter)<br><br>has to point to a real function and connot be just called.<br>just to check to see if you knew that, however it would be nice if you were more clear on what you were using, and how so. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
Hi there thank you for replying. In the main a funtion I&nbsp;&nbsp;called a display function. The display function is only supposed to show what these 3 functions return. I tried by typing objectname.getisbn(), but like I said before it does not work, so I am thinking that maybe the syntax is wrong but I am not getting any syntax errot it just crashes the program. <p>Villica<br><a href=mailto:villica67@hotmail.com>villica67@hotmail.com</a><br><a href= > </a><br>
 
can I see the class declaration the object, if you wrote the class. might help, sometimes when a class object has a variable that is say beyond the bounds, for example a char array without a null terminator, the program might crash when allocating, or deallocating memory. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
Hey these functions are supposed to return the pointers . So please take care that when they return any pointer , they are properly null terminated. Nothing complex about that. Nice if you show the code. <br><br>Eg. <br>class A {<br>public:<br>char* fun() cost;<br>}<br>can be called as<br>A a<br>char temp[10];<br>strcpy(temp,a.fun());<br><br>Does it answer your question?<br><br>Thanx<br>Siddhartha Singh<br><A HREF="mailto:ssingh@aztecsoft.com">ssingh@aztecsoft.com</A>
 
whats the cost hanging after the func()<br><br>if I wanted a function to return a pointer to a string<br>wouldnt it be char* func();<br>nothing after it?<br><br><br> <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
OOps actually it was &quot;const&quot; word after function.<br>It means that the function is not going to change the member variables of the class.<br><br>Does it answer the confusion?<br>Thanx<br>Siddhartha Singh<br><A HREF="mailto:ssingh@aztecsoft.com">ssingh@aztecsoft.com</A><br>
 
Thank you both of you for your help. It did help me figure out where my error was. Do you know if there is anything on the net regarding pointers. I need to have a better understanding. Thank you once again.<br><br> <p>Villica<br><a href=mailto:villica67@hotmail.com>villica67@hotmail.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top