Que BMW car manufacturing company which produces the hatchback car on order basis for its customer
depending upon the life style and liking of the customer.
Create a class CAR having minimum attributes like no of attributes
1. no_of_wheels
2. name_of _company
3. color_of_car
4. no_of_seats
5. color_of_interior_upholstery
6. type_of_transmission
7. power steering (Boolean value :- YES/NO)
do the following:
1. identify the class and instance variables
2. Use the parameterized constructor to initialize the value of instance variables.
3. Create minimum three objects in another class having main method and display the values of
variables.
My Code
#include<iostream.h>
#include<conio.h>
void car()
{
clrscr();
class car
{
private:
int w=4;
char com[]="BMW";
char color[];
char trans[];
char inter[];
int seat=5;
bool s;
public:
void power(bool x)
{
s = x;
if(s==true)
{
cout<<"car has a power steering";
}
else
{
cout<<"car does not have power steering");
}
{
car(char[] x)
{
color=x;
}
}
}
class Company
{
void main()
{
car c1 ("black");
car c2 ("petrol");
car c3 ("ivory");
cout<<"colour of car:"<<c1.color;
cout<<"transmission mode of car:"<<c2.color;
cout<<"colour of interior upholstry of car:"<<c3.color;
c1.power(true);
}
}
}
You've got this in your class definition. This is wrong. Your class definition is a description of a new kind of object. You do not set values in a class definition. It makes no sense. Exactly where would that value 4 be stored? You've not created any objects yet; in a class definition, you're just explaining to the compiler what this new object looks like - you're not actually creating one.
car c1 ("black");
THAT is where you create an object, and now that the object exists, NOW you can set some values in it.
Also, this void main() is NOT C++. It is NOT. If your compiler doesn't even warn you, throw it away and get a C++ compiler. If your textbook uses void main(), it's a bad book. If your teacher uses it, you're being taught some hideous language that looks a lot like C++ but isn't.
This
1 2
#include<iostream.h>
#include<conio.h>
indicates that you're using a very old compiler. A compiler that predates the C++ standard. A compiler that's probably a decade old or more. Throw it away and get a C++ compiler.
i am a very novice programmer pls try compiling this code in your pc and correct the possible errors and post the xorrected codes please its very urgent my 50 nos depends on this it would be very kind of you