ankit.kumar010203
Journeyman
Hello,
I am facing problem with my c++ coding
. How can i add these following sentences to my text file of notepad? I know that it is wrong. Please Help me...! How can I fix it? The code are as follow:-
#include <iostream>
#include <fstream>
using namespace std;
class cars{
public:
void introcar(){
cout << "Cars was invented by Nicolas Joseph Cugnot.\n";
cout << "Cars have 4 wheels and more than 5 doors.\n";
}
};
class maruti : public cars{
public:
void marutiinfo(){
cout << "Maruti Suzuki was founded by Sanjay Gandhi.\n";
cout << "Maruti Suzuki is one of the top Car company in the world.\n";
}
};
class swift : public maruti{
public:
void swiftinfo(){
cout << "Swift is one of the best model of Maruti Suzuki Cars.\n";
}
};
int main()
{
ofstream filename("Cars.txt");
swift ob1;
filename << ob1.introcar();
filename << ob1.marutiinfo();
filename << ob1.swiftinfo();
return 0;
}
I am facing problem with my c++ coding


#include <iostream>
#include <fstream>
using namespace std;
class cars{
public:
void introcar(){
cout << "Cars was invented by Nicolas Joseph Cugnot.\n";
cout << "Cars have 4 wheels and more than 5 doors.\n";
}
};
class maruti : public cars{
public:
void marutiinfo(){
cout << "Maruti Suzuki was founded by Sanjay Gandhi.\n";
cout << "Maruti Suzuki is one of the top Car company in the world.\n";
}
};
class swift : public maruti{
public:
void swiftinfo(){
cout << "Swift is one of the best model of Maruti Suzuki Cars.\n";
}
};
int main()
{
ofstream filename("Cars.txt");
swift ob1;
filename << ob1.introcar();
filename << ob1.marutiinfo();
filename << ob1.swiftinfo();
return 0;
}