I'm trying to make a vector with the class type MyClass. Why do the functions v.size () and v.capacity () work fine, and v.pop_back () and v.front () don't work? It does not display anything after running the program.
class MyClass { public: MyClass(int x = 1) : xp(x) {} int x() const { return xp; } private: int xp; }; int main() { setlocale(LC_ALL, "Russian"); vector<MyClass> v {7, 9, 8}; cout << "\n\tВектор с пользовательским типом данных"; cout << "\n\tСодержимое вектора: "; for (const auto& f : v) { cout << fx() << std::endl; } cout << "\tsize(): " << v.size() << endl; cout << "\tcapacity(): " << v.capacity() << endl; cout << "\n\tЭлемент с индексом 1 - > " << endl; v.pop_back(); cout << "\n\tПервый элемент в векторе: " << endl; v.front(); }