class myclass {
public:
myclass();
myclass(int);
void func();
~myclass();
};
What I am currently doing is like:
myclass::myclass() {
cout << "Default Constructor";
}
myclass::myclass(int a) {
cout << "Normal Constructor";
}
void myclass::func(){
cout<< "function f";
}
But every definition needs myclass::
, which seems messy.
Can I do something like:
myclass::{
myclass(){...}
myclass(int a){...}
void f(){...}
}
Gathering all the member functions under the same class and define them together?
Can I do something like: ... Gathering all the member functions under the same class and define them together?
Not when defining the functions outside the class definition. Repeating the class name for each member function is necessary in that case.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.