I have been trying to invoke the default destructor for a class of mine (see below). when I try I get this error:
"no match for 'operator~' in '~Card(((const Card&)((const Card*)(& hearts[1]))))'"

class Card
{
    public:
    bool inPlayer;
    bool inDeck;
    bool inOpp;//in opponets hand.

        int type; //!< Member variable "type" (1-Ace(A))
        string suit; //!< Member variable "suit" (Heart,Diamond,Spade,Club)
void present()//!< says the type of card you have.
{
    cout << type << "of " << suit << "'s";
}
};

This is where I am using the class and its destructor. The instance is in an array

~Card(hearts[1]);//I am not sure if this is even right

I want to use the default destructor for this class, it has no need to have a special destructor... or at least I don't think so.
I am trying to make a command line card game.

~Card(hearts[1]);//I am not sure if this is even right

It's not. Destructors take no arguments and are called automatically. They should also be virtual whenever the object might be polymorphic.

It is possible to invoke an object's Destructor, if you define your own, but it's not recommended because it's likely to cause errors when the object is actually destroyed.

You're better off destroying the actual object. The Destructor will be automatically invoked for you as part of that process.

I think the appropriate question in this case is why do you want to invoke the destructor explicitly? It's called automatically at the right time except in some extreme and obscure situations (which you're not likely to encounter for a while).

I Think that this would be helpful so that I could burn cards in a card game. This would not allow users to cheat by accessing a burnt card.

Okay, I can see what you were thinking now. It won't work, but at least it's logical from a beginner's perspective. ;) If you want to burn cards, simply remove them from the deck somehow (how depends completely on how your deck is designed). There's no need to explicitly call the destructor.

OK, mabye I could throw a variable in there that says if the card is active. If it's not and a person tries to access it. The program could accuse them of cheating.

I would think something like this:

class Card
{
    public:
    bool inPlayer;
    bool inDeck;
    bool inOpp;//in opponets hand.
bool activeCard;//I already have an active var, so that I don't confuse myself with overloading.
//this is the new var.

        int type; //!< Member variable "type" (1-Ace(A))
        string suit; //!< Member variable "suit" (Heart,Diamond,Spade,Club)
void present()//!< says the type of card you have.
{
    cout << type << "of " << suit << "'s";
}
};

Please post the code relevant to creation and management of your deck of cards and dealing. There is probably a better way to do this, but we don't know how your code works so it's difficult for us to make good suggestions.

Here it is:

Card hearts[13];
Card diamonds[13];
Card spades[13];
Card clubs[13];

I have a loop that will assign the values to the cards.

I don't have an idea for the dealing yet...
seeing as this is my 3rd day working on this mini-project, I havn't had time to think all of that out.
What do you guys think about the dealing issue?

I am not sure how far along you are but this is a great example of when to use polymorphism. If you think about it, Spades, hearts, diamonds and clubs are all cards so why not make a base class Card and then child classes for the different suits.

Ex.

class Card
{
   //Insert code and methods for base class
   // Should be methods and attributes that can apply to all suits
};

class Spade : public Card
{
   // Insert methods and attributes specific to the spade suit
};

// Do that for the three other suits

// When you need to declare them
Card *hearts[13];
Card *diamonds[13];
Card *spades[13];
Card *clubs[13];

// In your for loop
spades[index] = new Spade();

// Do that for all suits

that seems like a great idea, but the problem is is that what if I need to accsess things about the class as a whole like how many cards are left in the deck and other things (static). I loose this (I think) when I use the child clasess...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.