0
Structure c++
Can a struct data type is defined with it own method like a class definition? Method in class is called class Method. Does we call structure method for mathod defined inside a structure if any?
1 Respuesta
+ 2
"Can a struct data type is defined with it own method like a class definition?"
A C++ structure can have methods, including special ones like constructor & destructor etc.
* In C language, a structure is plain data package, a composite
https://shorturl.at/utbev
* The following pages will enlighten you on the differences between a class and a structure.
https://www.fluentcpp.com/2017/06/13/the-real-difference-between-struct-class/
https://stackoverflow.com/questions/92859/what-are-the-differences-between-struct-and-class-in-c
"Method in class is called class Method."
No, class methods are methods defined with `static` keyword. Class methods are callable directly by specifying the class name followed by scope resolution operator, like so (just an illustration)
ClassName::MethodName();
On the other hand, there can be methods referred to as instance methods. These, just like any instance (object) scoped members, requires an instance (object of the said class) to be instantiated prior to the use of the member (method call for example).
"Does we call structure method for mathod defined inside a structure if any"
Sorry, I don't think I'm understanding that line clearly. Can you please edit the Description so I can understand it better?
P.S. In C++, a method also commonly referred by "member function"
(Edited)