GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 14-May-2008, 07:50
khushal_kkk's Avatar
khushal_kkk khushal_kkk is offline
Junior Member
 
Join Date: Mar 2008
Posts: 42
khushal_kkk is on a distinguished road

need help in OOP In C++


i want add the car details in car1 i want enter the model of the car through the user while in car2 i want the model to be already entered in the program it doesnt do my job...my code is here


CPP / C++ / C Code:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
 
class car
{
 
    char company[30],tyres[30],engine[30];
    float price,power;
    int model;
 
public:
     void ReadData()
        {
        cout<<endl<<"Enter The Car Company Name :";
        cin>>company;
        cout<<"Enter The Tyres Name :";
        cin>>tyres;
     cout<<"Enter The Engine Name :";
     cin>>engine;
        //cout<<"Enter The Price Of The Car :";
     //    cin>>price;
        cout<<"Enter The Engine Power :";
        cin>>power;
     //    cout<<"Enter The Car Model :";
     //    cin>>model;
        }
        void PrintData()
            {
            cout<<"\nThe Company Name Is :"<<company;
            cout<<"\nThe Tyres Company Name Is :"<<tyres;
            cout<<"\nThe Engine Name Is :"<<engine;
            cout<<"\nThe Price Of The Car Is :"<<price;
            cout<<"\nThe Power Of The Engine Is :"<<power;
            cout<<"\nThe Model Of The Car Is :"<<model;
            }
            car(float p,int q)
            {
            price=p;
            model=q;
            power=0;
            strcpy(engine,"NA");
            strcpy(tyres,"NA");
            strcpy(company,"NA");
            }
            car(float p)
            {
            price=p;
            model=0;
            power=0;
            strcpy(engine,"NA");
            strcpy(tyres,"NA");
            strcpy(company,"NA");
            }
 
 
};
 
 
void main()
{
clrscr();
    car car1(45.908f),car2(546.98f,2008);
    car1.ReadData();
    car2.ReadData();
    car1.PrintData();
    car2.PrintData();
    getch();
}
__________________
K K K
Last edited by admin II : 14-May-2008 at 17:17. Reason: Please surround your C++ code with [cpp] your code [/cpp]
 
 

Recent GIDBlogWelcome to Baghdad by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:41.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.