I can understand the first row and last two rows.
However, does anyone know what the remaining part means ????(line3-line16)
especially for line3-line5
struct Bracket
{
Bracket(char type, int position);
bool Matchc(char c);
char type;
int position;
};
Bracket::Bracket(char type, int position)
: type(type), position(position)
{}
bool Bracket::Matchc(char c)
{
if (type == '[' && c == ']')
returntrue;
if (type == '{' && c == '}')
returntrue;
if (type == '(' && c == ')')
returntrue;
returnfalse;
}
Have you seen terms member function and constructor anywhere? They are usually mentioned with classes, but in C++ class and struct are very similar. With constructor, one can learn about initializer list.
Lines 3-6 are a constructor. However, lines 4-5 are problematic. The argument names conflict with the member variables at lines 17-18. Lines 4-5 initialize the arguments to themselves.
Lines 7-16 are a simple member function that checks if type and c are matching types of brackets, braces or parens. If so, true is returned. If not, false is returned.
PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
Do not number the lines yourself.