Queue implementation of array

code : https://ide.codingblocks.com/s/217437

why we are using THIS keyword in the lecture… i am not getting.
also the result is coming same with or without THIS keyword

also what is the significance of default size in constructor?

@chaman9 this keyword just implies that the variable we are talking about is a member of this class, and not some other variable. It becomes significant in a case where you have a function like this

void func(int data) {
this->data = data;
}
now suppose you have a member called “data” in your class, and the argument in the function is also “data”, so to avoid conflict you can use the “this” keyword to make it clear to the compiler that the first data is from the data memebers, otherwise it’d take it to be the " data" that is locally available, ie the function argument.

@chaman9 for your second query, if we dont provide a size for the queue by ourselves, it shouldn’t raise an error, so we give it a default max size, in case nothing is provided

okay thanks… it helped a lot

1 Like