Private Void

Private Void




⚡ ALL INFORMATION CLICK HERE 👈🏻👈🏻👈🏻

































Private Void

Sign up or log in to customize your list.

more stack exchange communities

company blog


Stack Overflow for Teams
– Start collaborating and sharing organizational knowledge.



Create a free Team
Why Teams?



Asked
6 years, 9 months ago


Modified
6 years, 9 months ago


16.2k 6 6 gold badges 50 50 silver badges 60 60 bronze badges



Sorted by:


Reset to default





Highest score (default)


Trending (recent votes count more)


Date modified (newest first)


Date created (oldest first)




9,391 4 4 gold badges 36 36 silver badges 54 54 bronze badges


Stack Overflow

Questions
Help



Products

Teams
Advertising
Collectives
Talent



Company

About
Press
Work Here
Legal
Privacy Policy
Terms of Service
Contact Us
Cookie Settings
Cookie Policy



Stack Exchange Network



Technology




Culture & recreation




Life & arts




Science




Professional




Business





API





Data






Accept all cookies



Customize settings


Find centralized, trusted content and collaborate around the technologies you use most.
Connect and share knowledge within a single location that is structured and easy to search.
So for this assignment I have to use 3 methods and have it display the correct things, but I can't seem to figure out how to call my methods I have made. I've looked at my book and searched online and can't find anything. Hoping someone can help me!
How do I call these methods for the when the button is clicked it will display what the method states?
You cannot call private members from outside the containing classes scope (Reflection let aside).
For the members to be callable from other classes/objects, those members have to be at least internal (when the caller resides in the same assembly) or public .
If the calling class inherits from the class containing the members, the protected modifier would also work.
Thanks for contributing an answer to Stack Overflow!

By clicking “Post Your Answer”, you agree to our terms of service , privacy policy and cookie policy

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2022 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2022.9.6.42960


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .






Table of contents



Exit focus mode





















Light



















Dark



















High contrast























Light



















Dark



















High contrast




This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
You use void as the return type of a method (or a local function ) to specify that the method doesn't return a value.
You can also use void as a referent type to declare a pointer to an unknown type. For more information, see Pointer types .
You cannot use void as the type of a variable.



Sign up or log in to customize your list.

more stack exchange communities

company blog


The best answers are voted up and rise to the top


Stack Overflow for Teams
– Start collaborating and sharing organizational knowledge.



Create a free Team
Why Teams?



Asked
4 years, 10 months ago


Modified
4 years, 10 months ago



Sorted by:


Reset to default





Highest score (default)


Date modified (newest first)


Date created (oldest first)




125k 27 27 gold badges 264 264 silver badges 349 349 bronze badges


Software Engineering

Tour
Help
Chat
Contact
Feedback



Company

Stack Overflow
Teams
Advertising
Collectives
Talent
About
Press
Legal
Privacy Policy
Terms of Service
Cookie Settings
Cookie Policy



Stack Exchange Network



Technology




Culture & recreation




Life & arts




Science




Professional




Business





API





Data






Accept all cookies



Customize settings



Stack Exchange network consists of 182 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.
Connect and share knowledge within a single location that is structured and easy to search.
I am currently writing a class that performs a rather complex computation that should be triggered by one function call.
The steps of using the class would be:
Step 2 is separated from step 1 so you can perform multiple computations with the same parameters by simply changing the case specific ones instead of creating a new object.
The large computation shall now be separated into several auxiliary functions. My approach for this is using private void functions that only handle class variables, e.g.,
where doTheActualComputation calls computeThisAndThat and computeSomeInterimResults .
Is this use of private functions good practice? Or should I rather put all the auxiliary stuff into an anonymous namespace? This would result in passing lots of arguments to the functions in the anonymous namespace, also some complex container stuff.
Please note that this question is not about passing arguments but rather about the use of void private member functions with the assumption that the mentioned interim results make sense as class variables as they actually describe the state of the class object.
Decomposing your code into private member functions is entirely OK. By itself, a void return type is not a problem: the function may have an external effect, or may change the state of the class.
But this changing state may be a problem. Your object stores both general state that is used across multiple computations (and likely should not change) and also temporary per-problem state. What happens then the computation throws an exception? It is often difficult to make sure the object is always in a valid state that can perform the next computation when it is reused like this.
It is often a better design to separate these different kinds of data. The per-computation interim results can be stored in an object that is not externally visible and can be thrown away afterwards. This makes managing the life cycle much simpler.
In the header, we define a class that stores the basic parameters and can perform the computation:
In the actual source code, we can now define the computation, and importantly: data structures for the per-computation params. We can use static functions or use an anonymous namespace to limit their visibility (technically: to ensure internal linkage):
Inside this file you are free to use member or non-member functions as is convenient. Non-member functions are workable here because most parameters are already bundled into a single object.
You do not have to leak your internal structure into the header (except of course if this is templated code). You can define whatever data structures you need. Since everything here is effectively private, you do not have to explicitly specify private visibility.
Thanks for contributing an answer to Software Engineering Stack Exchange!

By clicking “Post Your Answer”, you agree to our terms of service , privacy policy and cookie policy

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2022 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2022.9.6.42960


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .


Overwatch Mercy Gif
Body Art Nudists Beach
Mature Twitter

Report Page