Skip to content
View in the app

A better way to browse. Learn more.

Komuniti @PuTeRA

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Using Class,constructor,destructor And Accessor

Featured Replies

nk minta tolong terangkan mcm mane nk gune accesor untuk access data private dlm class tue conth:-

Class X{
private:
int w;
int u;
public:
print()const;
};

mcm nk print out data private tue dlm function print()const tue?
accessor nie bermaksud apabila sesuatu "member function" nie yg dpt value dr "class memmber" tetapi nilainye x berubah... 2 la accessor..

contoh:-
[code]
class rectangle
{
private:
double width;
double length;
public:
void setWidth(double);
void setLength(double);
double getWidth() const;
double getLength() const;
double getArea() const;
};
[/code]

"member function" getlength dan getWidth 2 la accessors..

kalau nak print out plak...
[code]
double rectangle::getWidth() const
{
return width;
}
[/code]

make sure value da pass dlm function main..
  • Author
kalau kt public tue ade function void print()const...mcm mane nk gune accessor tue dlm function print tue?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.