0

Is it possible to indicate that a class function you are calling is static?

class Point
{
std::string name;
	public:
		Point(){}
		static void DisplayName() { std::cout << "Point" << std::endl;}
};

int main()
{
  Point.DisplayName(); //this doesn't indicate the the member function is static
//maybe something like this:
//static_call(Point.DisplayName()); //just to indicate to the reader that this call makes sense without an instance of the class
}

There are several times where I dont remember even in my own code that I am calling a static function.

Thanks,

Dave

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by siddhant3s
0

Use the functions qualified name i.e. class_name::function_name(parameteres)

In your case, call it as: Point::DisplayName() This will make clear that DisplayName is either a static function from a class Point or it is a Simple function in the Point namespace.
If the code reader knows that Point is a class, he will surly understand that DisplayName is a static member.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.