Skip to main content
gamedev.net
🔒 Locked

Problem with pointers

Started by edd1986 2 replies 1k views
Original Post
edd1986
edd1986
Hello. In the app I am writing I have one class that contains several pointers to other class types, eg:

class Booking
{
   Customer* customer;
   Payment* payment;
}

Before creating a Booking object I create the necessary Customer and Payment objects and pass a pointer to these when creating the Booking:

Booking(Customer* c, Payment* p)

and assign them as follows:

customer = c;
payment = p;

The problem is this doesn't assign them properly, in debug mode if I hover over 'c' or 'p' then it shows the correct details, however if I hover over 'customer' or 'payment' then random garbage is there. Then later in my code I call functions from customer and payment eg;

customer->commit();

Now as far as I can tell this function is carried out correctly sometimes, and other times it isn't which really confuses me. Am I doing something silly with my pointers, or should I perhaps not be using them? Thanks in advance
Sneftel
Sneftel
Moved to For Beginners.
yaustar
yaustar
Can you post up the code where you use and declare your Booking Objects?
Steven Yau
[Blog] [Portfolio]
edd1986
edd1986
Hi thanks for replying, I feel really silly because the problem wasn't even with pointers.

Could a moderator please delete this thread

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.