Junior — Middle
Could you list the main method specifiers in programming languages?
sobes.tech AI
Answer from AI
In C and C++ languages, method (function) specifiers define the scope, behavior, and properties of functions. Main specifiers:
static— limits the visibility of the function to the current file (in C) or makes the class method static (in C++).extern— indicates that the function is defined elsewhere (commonly used in C).inline— suggests to the compiler to embed the function instead of calling it for optimization.virtual(only in C++) — allows methods to be overridden in derived classes, supporting polymorphism.const(in C++) — indicates that the method does not modify the state of the object.friend(C++) — allows a function or class to access private members of the class.
Example in C++:
class MyClass {
public:
static void staticMethod(); // static method
virtual void virtualMethod(); // virtual method
void constMethod() const; // method that does not modify the object
};
In C, function specifiers are usually limited to static, extern, and inline.