Chào tất cả,
Mình đang lập trình OOP C++ trên android dùng app Mobile C của Lee Jeong Seop. Tìm trên stackoverflow thì nó nói lỗi này là phụ thuộc vào phần cứng và nền tảng hệ điều hành gì đó, nhưng mình thấy còn mơ hồ quá, xin các bác chỉ giáo thêm. Code mình đây
#include <iostream>
using namespace std;
class Time {
int h, min,sec;
public :
Time(int a, int b,int c) {
h = a;
min = b;
sec = c;
}
Time() {
h = min = 0;
}
void show() {
cout<<h<<" Hours "<<min;
cout<<" minutes "<< sec<<" sec.\n";
}
Time operator=(Time t){
h = t.h;
min = t.min;
sec = t.sec;
return Time(h,min,sec);
}
friend Time operator>>(istream &ob,Time &t);
friend Time operator<<(ostream &ob,Time &t);
};
Time operator>>(istream &ob,Time &t){
cout<<"Enter Time ";
ob>>t.h;
ob>>t.min;
ob>>t.sec;
}
Time operator<<(ostream &ob,Time &t){
ob<<t.h<<"::"<<t.min;
ob<<"::"<< t.sec<<endl;
}
int main() {
Time t;
cin>>t;
cout<<t;
t.show();
Time t2,t3(5,10,30);
t2 = t3;
t3.show();
return 0;
}