Cho mình hoi chút, ở ham Useless::Useless(int k) : n(k){…} thì dấu “:” nghĩa là gì ạ?
using namespace std;
// interface
class Useless {
private:
int n; // number of elements
char *pc; // pointer to data
static int ct; // number of objects
void ShowObject() const;
public:
Useless();
explicit Useless(int k);
Useless(int k, char ch);
Useless(const Useless &f); // regular copy constructor
Useless(Useless &&f); // move constructor
~Useless();
Useless operator+(const Useless &f) const;
// need operator=() in copy and move versions
void ShowData() const;
};
// implementation
int Useless::ct = 0;
Useless::Useless() {
++ct;
n = 0;
pc = nullptr;
cout << "default constructor called; number of objects: " << ct << endl;
ShowObject();
}
Useless::Useless(int k) : n(k) {
++ct;
cout << "int constructor called; number of objects: " << ct << endl;
pc = new char[n];
ShowObject();
}

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?