473,511 Members | 15,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to pass values of variables from a redefined function into another function

Here's the problem:
I have a function that references another one in this manner:
class circleType: public pointType
so, pointType is redefined by circleType, thereby giving circleType access
to all the functions in pointType if need-be. Here is the function I am
using in pointType:

void pointType::setCoords(double xCoord, double yCoord)
{
pointX = xCoord;
pointY = yCoord;
}

it is being accessed in circleType in this manner:

void circleType::getCoords(double xCoord, double yCoord)
{
//set the external point using the pointType header
pointType::setCoords(pointX, pointY);
cout << "The coordinate entered is: (" << pointX << "," << pointY << ")";
cout << endl;
}

My cout works, but the point it prints is (0,0), meaning that the variables
aren't being passed into the function, and it is just defaulting to the
value of 0 for both.

Any thoughts?
Oct 23 '05 #1
4 1486

deanfamily wrote:
Here's the problem:
I have a function that references another one in this manner:
class circleType: public pointType
so, pointType is redefined by circleType, thereby giving circleType access
to all the functions in pointType if need-be. Here is the function I am
using in pointType:

void pointType::setCoords(double xCoord, double yCoord)
{
pointX = xCoord;
pointY = yCoord;
}

it is being accessed in circleType in this manner:

void circleType::getCoords(double xCoord, double yCoord)
{
//set the external point using the pointType header
pointType::setCoords(pointX, pointY);
cout << "The coordinate entered is: (" << pointX << "," << pointY << ")";
cout << endl;
}

My cout works, but the point it prints is (0,0), meaning that the variables
aren't being passed into the function, and it is just defaulting to the
value of 0 for both.

Any thoughts?


Code isn't very descriptive but seem as though you're passing
uninitialized member variables of the pointType to PointType:

void circleType::getCoords(double xCoord, double yCoord)
{
//set the external point using the pointType header
pointType::setCoords(pointX, pointY);

....
did you mean: pointType::setCoords(xCoord, yCoord) ?

Oct 23 '05 #2
Even with it corrected to
void circleType::getCoords(double xCoord, double yCoord)
{
//set the external point using the pointType header
pointType::setCoords(xCoord, yCoord);
cout << "The coordinate entered is: (" << pointX << "," << pointY << ")";
cout << endl;
}
it still isn't passing the amounts.

"puzzlecracker" <ir*********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...

deanfamily wrote:
Here's the problem:
I have a function that references another one in this manner:
class circleType: public pointType
so, pointType is redefined by circleType, thereby giving circleType
access
to all the functions in pointType if need-be. Here is the function I am
using in pointType:

void pointType::setCoords(double xCoord, double yCoord)
{
pointX = xCoord;
pointY = yCoord;
}

it is being accessed in circleType in this manner:

void circleType::getCoords(double xCoord, double yCoord)
{
//set the external point using the pointType header
pointType::setCoords(pointX, pointY);
cout << "The coordinate entered is: (" << pointX << "," << pointY <<
")";
cout << endl;
}

My cout works, but the point it prints is (0,0), meaning that the
variables
aren't being passed into the function, and it is just defaulting to the
value of 0 for both.

Any thoughts?


Code isn't very descriptive but seem as though you're passing
uninitialized member variables of the pointType to PointType:

void circleType::getCoords(double xCoord, double yCoord)
{
//set the external point using the pointType header
pointType::setCoords(pointX, pointY);

....
did you mean: pointType::setCoords(xCoord, yCoord) ?

Oct 23 '05 #3
deanfamily wrote:
Here's the problem:
I have a function that references another one in this manner:
class circleType: public pointType
This means nothing. Be careful to use the correct terms for the
concepts. What's more, some code is worth a thousand words, so they
say.
so, pointType is redefined by circleType, thereby giving circleType access
to all the functions in pointType if need-be. Here is the function I am
using in pointType:

void pointType::setCoords(double xCoord, double yCoord)
{
pointX = xCoord;
pointY = yCoord;
}

it is being accessed in circleType in this manner:

void circleType::getCoords(double xCoord, double yCoord)
get or set?
{
//set the external point using the pointType header
pointType::setCoords(pointX, pointY);
cout << "The coordinate entered is: (" << pointX << "," << pointY << ")";
cout << endl;
}

My cout works, but the point it prints is (0,0), meaning that the variables
aren't being passed into the function, and it is just defaulting to the
value of 0 for both.


Something on line 42, perhaps?

Seriously, the code you gave is obviously correct, so some wild
guesses:
1) circleType also has members named pointX and pointY which takes
precedence over pointType's in the std::cout
2) you passed 0,0 when you called getCoords (or setCoords?)
3) another thread modify the variables
4) main returns void
5) you have a virus

What does the debugger says? Is there more code to this program?
Something we could test ourselves?
Jonathan

Oct 23 '05 #4

deanfamily wrote:
Even with it corrected to
void circleType::getCoords(double xCoord, double yCoord)
{
//set the external point using the pointType header
pointType::setCoords(xCoord, yCoord);
cout << "The coordinate entered is: (" << pointX << "," << pointY << ")";
cout << endl;
}
it still isn't passing the amounts.

"puzzlecracker" <ir*********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...

deanfamily wrote:
Here's the problem:
I have a function that references another one in this manner:
class circleType: public pointType
so, pointType is redefined by circleType, thereby giving circleType
access
to all the functions in pointType if need-be. Here is the function I am
using in pointType:

void pointType::setCoords(double xCoord, double yCoord)
{
pointX = xCoord;
pointY = yCoord;
}

it is being accessed in circleType in this manner:

void circleType::getCoords(double xCoord, double yCoord)
{
//set the external point using the pointType header
pointType::setCoords(pointX, pointY);
cout << "The coordinate entered is: (" << pointX << "," << pointY <<
")";
cout << endl;
}

My cout works, but the point it prints is (0,0), meaning that the
variables
aren't being passed into the function, and it is just defaulting to the
value of 0 for both.

Any thoughts?


Code isn't very descriptive but seem as though you're passing
uninitialized member variables of the pointType to PointType:

void circleType::getCoords(double xCoord, double yCoord)
{
//set the external point using the pointType header
pointType::setCoords(pointX, pointY);

....
did you mean: pointType::setCoords(xCoord, yCoord) ?


I second it. Perhaps, computer science is not really for you. Can you
still change the major?

Oct 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
9253
by: Randell D. | last post by:
Folks, I've asked this before but never got any response but its important and I thought I'd pitch it again (hopefully a bit clearer)... One can pass data from one function to another either...
46
3459
by: J.R. | last post by:
Hi folks, The python can only support passing value in function call (right?), I'm wondering how to effectively pass a large parameter, such as a large list or dictionary? It could achieved...
3
3469
by: drec | last post by:
I am creating a search box that the user types a value in, and then this gets passed to another page called search.php I would like to be able to pass these values through the URL, but I cant...
10
1537
by: tshad | last post by:
I want to access multiple arguments based on name passed. For example I have the following asp:textboxes: BillingAddress1 BillingAddress2 BillingCity ShippingAddress1 ShippingAddress2...
8
2309
by: laredotornado | last post by:
Hi, I want to pass my function myFunc('a', 'b', 'c') as an argument to another function. However, this will not work doStuff('x', 'y', myFunc('a', 'b', 'c'))
10
2201
arunmib
by: arunmib | last post by:
hi all, I just got this freaky kind of doubt....I have the following piece of code, int main() { int Val= 10, *ptr; ptr = &Val; TestFn(&Val);
6
2698
by: lisp9000 | last post by:
I've read that C allows two ways to pass information between functions: o Pass by Value o Pass by Reference I was talking to some C programmers and they told me there is no such thing as...
12
2996
by: Bryan Parkoff | last post by:
I write my large project in C++ source code. My C++ source code contains approximate four thousand small functions. Most of them are inline. I define variables and functions in the global scope....
13
3701
by: magickarle | last post by:
Hi, I got a pass-through query (that takes about 15 mins to process) I would like to integrate variables to it. IE: something simple: Select EmplID from empl_Lst where empl_lst.timestamp between...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7349
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4734
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3219
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.