#include <iostream>
using namespace std;
class VongLap{
public:
VongLap(int a, int b){
for(a = 1, b = 10; a <= 10 && b >= 1; a++, b--){
cout << a << " " << endl;
cout << " " << b << endl;
}
}
// Vong Lap a b c la bang cuu chuong tu 1 den 9, lololololol. Khong the tin duoc :))
/*VongLap(int a, int b, int c){
for(a = 1; a <= 10; a++){
for(b = 1; b <= 10; b++){
cout << (b*a) << endl;
for(c = 10; c <= 5; c--){
cout << " " << b * a + c << endl;
}
}
}
}*/
public:
void TimUoc(int a, int bienchay){
cout << "Tim uoc nho nhat cua 1 so" << endl;
cout << "Moi ban nhap vao 1 so : ";
cin >> a;
for(bienchay = a + 1; bienchay >= a; bienchay++){
if(bienchay % a == 0){
cout << "Uoc chung nho nhat cua " << a << " la " << bienchay << endl;
number = bienchay;
break;
}
}
}
private:
int number;
};
int main(){
int a, b, c;
a = b /*c*/ = 0;
int x, bien;
x = bien = 0;
VongLap BienGoi(a, b);
VongLap BienGoi2;
//VongLap BaiToanTimUoc;
//BienGoi.TimUoc(x, bien);
BienGoi2.TimUoc(x, bien);
//VongLap BienGoi2(a, b, c);
system("pause");
return 0;
}
Lỗi:
Warning 1 warning C4101: ‘c’ : unreferenced local variable c:\documents and settings\admin\desktop\project c++\all developments\vòng lặp ‘for’\bài 1\bài 1.cpp 39
2 IntelliSense: no default constructor exists for class “VongLap” c:\documents and settings\admin\desktop\project c++\all developments\vòng lặp ‘for’\bài 1\bài 1.cpp 44
Còn khi em sử dụng BienGoi.TimUoc(x, bien); thì nó lại được, sử dụng class để tạo ra 2 thực thể là k đc hả mấy anh, chỉ đc tạo 1 thực thể thôi hả ??