Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8951087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:34:53+00:00 2026-06-15T13:34:53+00:00

class AA { public: AA (); static void a1 (); static std :: string

  • 0
class AA
{
    public:
        AA ();
        static void a1          ();
        static std :: string b1 ();
        static std :: string c1 (unsigned short x);
};

My class won’t have different objects interacting with among themselves or with others.
Of course I need to have at least one object to call the functions of this class, so I thought of making the members static so that unnecessary object creation can be avoided.

What are the pros and cons of this design? What will be a better design?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:34:54+00:00Added an answer on June 15, 2026 at 1:34 pm

    Should members of a class be turned static when more than one object creation is not needed?

    You make members of the class static when you need only one instance of the member for all objects of your class. When you declare a class member static the member becomes per class instead of per object.

    When you say you need only one object of your class, You are probably pointing towards the singleton design pattern. Note that pattern is widely considered an anti pattern and its usefulness if any is dependent to specific situations.

    The reason you mention in Q is no way related to whether you should make a member static or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

class CommandManager { public: void sendText(std::string command); static bool CommandManager::started; private: bool parseCommand(std::string commands);
I have a class as outlined below: class InputReader { public: typedef void (*handler)(std::string,
#include <iostream> #include <string> class c1 { public: static std::string m1; static unsigned int
class Test { public static void main(String[] args) throws Exception { Test t =
class D { public static void main(String args[]) { Integer b2=128; Integer b3=128; System.out.println(b2==b3);
class x{ public static void main(String[] args){ String x=<html><head></head></html>; String arr[]=x.split(<head>); String script=hi; x=arr[0]+<head>+script+arr[1];
public class Test { public static void main(String[] args) { DemoAbstractClass abstractClass = new
public class Foo { public static void main(String[] args) { float f; System.out.println(f); }
public class MultiplicationTable { public static void main (String[]a){ int[] x; x = new
public class TestBL { public static void AddFolder(string folderName) { using (var ts =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.