Steffan Harris
Steffan Harris

Reputation: 9326

Using a pointer on a class method : Expression must have type bool error

So, I have a string* which I used for a dynamic array. But when I try to use a string method on it, I get the error Expression must have type bool.

For Instance, I get the error when I try to do it on this piece of code

while((!board[i].clear())
{

}

Upvotes: 0

Views: 1033

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 596156

Assuming you are using the std:string class, it's clear() method has a void return type. You cannot use it in a boolean expression like you are attempting to.

EDIT

Link for you string clear method

Upvotes: 1

Related Questions