Converting from "KanjiCard *" to the non-scalar type "KanjiCard" (custom enumeration)

Well, I tried using Google Sensei and searching on this website, and although I found a lot of posts about this error, I did not find the addresses that addressed the enumerations. In addition, all those whom I saw, or someone tried to assign one type to another, but also incorrectly use the "new", etc. As far as I can tell, this is not the case in this case.

As indicated in the header, I get an error conversion from 'KanjiCard*' to non-scalar type 'KanjiCard' requestedwhen trying to compile a program that I'm working on using g ++.

I have a class called KanjiCard that has this public enumeration:

enum KanjiCardType {
    KANJI_CARD = 1,
    KEYWORD_CARD = 2
};

The constructor for the class is defined as follows:

    KanjiCard(char *cardText, int cardTextLength, int cardWidth, int cardHeight,
        int cardX, int cardY, KanjiCardType cardType, SDL_Color textColor);

( char * std::string, , .)

( ):

KanjiCard currentCard = new KanjiCard(kanji_line, strlen(kanji_line), 
    CARD_WIDTH, CARD_HEIGHT, xPos, yPos, cardType, textColor);

cardType : KanjiCard::KanjiCardType cardType = KanjiCard::KANJI_CARD;

KanjiCard::KANJI_CARD, cardType , , , , , cardType *cardType &cardType cardType , .

, cardType , , . , , .

: , (, , KanjiCard::), .

+5
2

cardType, ; currentCard. :

KanjiCard currentCard = new KanjiCard(...

. , :

KanjiCard *currentCard = new KanjiCard(...

... , , :

KanjiCard currentCard(...

KanjiCard . currentCard KanjiCard. . KanjiCard.

delete. delete d; , , , .

->. ..

+5

Do

KanjiCard currentCard = KanjiCard(
    kanji_line, strlen(kanji_line), CARD_WIDTH, CARD_HEIGHT, xPos, yPos, cardType, textColor
    );

KanjiCard currentCard(
    kanji_line, strlen(kanji_line), CARD_WIDTH, CARD_HEIGHT, xPos, yPos, cardType, textColor
    );

, .

, new.

hth.,

+2

All Articles