Похожие чаты

Also why does your area method need any parameters?

13 ответов

4 просмотра

That's because these methods will accept some values from the user to calculate the area and volume of the shape

Daisuke Kambe
That's because these methods will accept some valu...

Why would your area and volume methods accept values from user?

Manav | avoid unnecessary messaging me
Why would your area and volume methods accept valu...

Okay all the child classes has a getter and setter for user input

Daisuke Kambe
Okay all the child classes has a getter and setter...

The user will provide some input, the area and Volume will use this input to calculate the area and volume

Manav | avoid unnecessary messaging me
Exactly.

What exactly does getters and setters do? As per my knowledge getters returns the value of class members And setters set the value of class members

Daisuke Kambe
What exactly does getters and setters do? As per ...

Getters get the member variables, setters set the member variables. It's just a name for methods which do these

Manav | avoid unnecessary messaging me
Getters get the member variables, setters set the ...

Yeah and for calculating the area and Volume I need to pass these members

Daisuke Kambe
Yeah and for calculating the area and Volume I nee...

Again why would you want to pass these parameters to area and volume? member functions (methods) already have access to members variables

Daisuke Kambe
Yeah and for calculating the area and Volume I nee...

class A { // member variables double my_member_variable_of_A; // method (member functions) void fun() { my_member_variable_of_a = 5.0; // see you can access them here } double another_method() { return my_member_variable_of_a; } }

Ohh okay if a method is defined within class scope it doesn't need to have parameters for accessing the members variables got it

Daisuke Kambe
Ohh okay if a method is defined within class scope...

That is a weird way if phrasing it but, yeah. A class's methods can access it's member variables and even other methods it has.

Manav | avoid unnecessary messaging me
class A { // member variables double my_membe...

Btw @Dabjazz the another_method() is a getter for my_member_variable_of_a It is not a good coding practice to have these weird names for getters though.

Похожие вопросы

Обсуждают сегодня

30 BCH videos in Hausa Language successfully delivered. In December 2023, I created a Flipstarter to produce Bitcoin Cash videos in the Hausa language for greater outreach an...
Munnir
5
читать файл максимально быстро? странный вопрос))
zamtmn
53
братва! где куличи брать?
Alöscha
25
тоесть, указав return eax, сгенерируется никому ненужная инструкция mov eax,eax ?
Aiwan \ (•◡•) / _bot
24
Посоветуйте пожалуйста аудио плеер для библиотеки mp3- FLAC на компьютере. На Винде пользовался Aimp, в том числе для конвертации. Много нужных команд было прямо в контекст...
Виктор Кузнецов
31
Is FXTL another frax ecosystem token? Why need fxtl when there is already fxs? Why cant I find a straight answer for this? Maybe thats why people think its all so complicated
MBD Tan
11
Hi guys , do we have update on voting?
HB
16
How Much Btc Falling Down ?
Suriya
22
Kda trading volume is too low recently of 2.5 mil. Worried exchanges make money from trading volume and they may consider to delist kda as it makes no money for them especiall...
Arooo
8
Why build it new? Why not try and get projects like fjord foundry etc. to launch? There is more power in getting real adoption and other teams on than to start everything a ne...
Qrayon Shinchan
11
Карта сайта