#include <iostream> #include <string> using namespace std; class Ceptelefonu { public:…
- User
#include #include using namespace std;
class Ceptelefonu { public: string marka; string model; double fiyat; bool aramaDurum; bool mesajDurum;
codeCeptelefonu(string _marka, string _model, double _fiyat) { marka = _marka; model = _model; fiyat = _fiyat; aramaDurum = false; mesajDurum = false; } void arama() { aramaDurum = true; cout << "Cep telefonu arama durumu: " << (aramaDurum ? "aranıyor" : "Arama yapmıyor") << endl; } void mesaj() { mesajDurum = true; cout << "Cep telefonu mesaj durumu: " << (mesajDurum ? "... kadar mesaj var " :"mesajınız yok"; }};
int main() { Ceptelefonu telefon1("Samsung", "Galaxy S10", 1500); Ceptelefonu telefon2("iPhone", "11 Pro", 2000);
codecout << "Telefon 1: " << telefon1.marka << " " << telefon1.model << ", Fiyat: " << telefon1.fiyat ; cout << "Telefon 2: " << telefon2.marka << telefon2.model << ", Fiyat: " << telefon2.fiyat; telefon1.arama(); telefon2.mesaj(); return 0;} bu kodu yazıp ERROR! g++ /tmp/FYUMQvF3Dq.cpp /tmp/FYUMQvF3Dq.cpp: In member function 'void Ceptelefonu::mesaj()': /tmp/FYUMQvF3Dq.cpp:29:103: error: expected ')' before ';' token 29 | saj durumu: " << (mesajDurum ? "... kadar mesaj var " :"mesajınız yok"; | ^
/tmp/FYUMQvF3Dq.cpp:29:50: note: to match this '(' 29 | cout << "Cep telefonu mesaj durumu: " << (mesajDurum ? "... kadar mesaj var " :"mesajınız yok"; | bu hatayı alıyor isem hata nerdendir
- Assistant
Bu hatayı alıyorsanız hata
"Cep telefonu mesaj durumu: "... kadar mesaj var " :"mesajınız yok";"satırında yer almaktadır. Burada iki tırnak işareti (") eksik olduğu için derleme hatası vermektedir. Doğru kodlama aşağıdaki gibi olmalıdır:cppvoid mesaj() { mesajDurum = true; cout << "Cep telefonu mesaj durumu: " << (mesajDurum ? "... kadar mesaj var " :"mesajınız yok"); }Bu şekilde hatayı ortadan kaldırabilirsiniz.
- User
düzeltir misinm
- Assistant
Tabii, kodu aşağıdaki gibi düzeltebilirsiniz:
cpp#include <iostream> #include <string> using namespace std; class Ceptelefonu { public: string marka; string model; double fiyat; bool aramaDurum; bool mesajDurum; Ceptelefonu(string _marka, string _model, double _fiyat) { marka = _marka; model = _model; fiyat = _fiyat; aramaDurum = false; mesajDurum = false; } void arama() { aramaDurum = true; cout << "Cep telefonu arama durumu: " << (aramaDurum ? "aranıyor" : "Arama yapmıyor") << endl; } void mesaj() { mesajDurum = true; cout << "Cep telefonu mesaj durumu: " << (mesajDurum ? "... kadar mesaj var " :"mesajınız yok") << endl; } }; int main() { Ceptelefonu telefon1("Samsung", "Galaxy S10", 1500); Ceptelefonu telefon2("iPhone", "11 Pro", 2000); cout << "Telefon 1: " << telefon1.marka << " " << telefon1.model << ", Fiyat: " << telefon1.fiyat << endl; cout << "Telefon 2: " << telefon2.marka << " " << telefon2.model << ", Fiyat: " << telefon2.fiyat << endl; telefon1.arama(); telefon2.mesaj(); return 0; }