0

This code is showing error please help in this

#include <iostream> #include <string> using namespace std; class Car { public: string brand; string model; int year; }; int main() {  Car cObj1;  cObj1.brand = "BMW";  cObj1.model = "X5";  cObj1.year = 1999; Car carObj2; carObj2.brand = "Ford"; carObj2.model = "Mustang"; carObj2.year = 1969;  cout << cObj1.brand << " " << cObj1.model << " " << cObj1.year << "\n"; cout << carObj2.brand << " " << carObj2.model << " " << carObj2.year << "\n"; return

22nd Mar 2021, 11:48 AM
Punitha C
Punitha C - avatar
3 odpowiedzi
+ 3
There may be an undentified character representing your whitespace instead of just plain whitespace. This may be caused by copying from other editors (or website examples). Another error is return should be return 0 (with semicolon) and a missing curly bracket (maybe just because of qna description character limit). Here's your code, I just retyped the whitespaces. I hope this is helpful. https://code.sololearn.com/cOJLaFPDjRxP/?ref=app
22nd Mar 2021, 12:04 PM
noteve
noteve - avatar
+ 1
Thank you so much!!
22nd Mar 2021, 12:18 PM
Punitha C
Punitha C - avatar
+ 1
Bit off topic, but if you want a space use ' ' not " " e.g std::cout << cObj.year << ' ' << ...
22nd Mar 2021, 1:26 PM
Maher Al Dayekh
Maher Al Dayekh - avatar