Introduction
Boolean variables are a type of data that can only have two values: true or false. In C++, boolean variables can be declared in a class by using the keyword “bool” followed by the variable name. This article will explain how to declare a boolean variable in a class in C++. It will also provide examples of how to use boolean variables in a class.
Solution
You can declare a boolean variable in a class in C++ by using the keyword “bool” followed by the name of the variable. For example:
bool myBooleanVariable;
You can declare a boolean variable in a class in C++ by using the keyword “bool” followed by the variable name. For example:
bool myBooleanVariable;
You should have a constructor to initialize class members:
class account {
char itemName[50];
double actualPrice;
bool empty;
public:
account() : empty(false) {} // this initializes the 'empty' variable to 'false'.
void create_account();
void displayRecord() const;
void drawLine3(int n, char symbol);
};
solved How can i declare a boolean variable in class in c++