Thread: beginer class program

  1. #1
    learner
    Guest

    beginer class program

    please look at this and help me make the class program work!
    class pet
    {
    public:
    pet(char,double,double,char,char);

    ~pet();
    private:
    char name[100];
    double height;
    double width;
    char breed[100];
    char type[100];
    };

    #include<iostream>

    using std::cout;
    using std::cin;
    using std::endl;


    #include<cstring>
    #include"pet.h"

    int main()
    {


    getname: char name);
    cin>>"ENTER NAME:">>getname;
    getheight: double height);
    cin>> "ENTER HEIGHT:" getheight;
    getwidth:double width);
    cin>>"ENTER WIDTH:">>getwidth;
    getbreed:char breed);
    cin>>"ENTER BREED:">>getbreed;
    gettype: char type);
    cin>> "ENTER TYPE:">>getype;

    cout<<"NAME:"<<getname endl;
    cout<<"HEIGHT:"<<getheight endl;
    cout<<"BREED:"<<getbreed endl;
    cout<<"TYPE:"<<gettype;

    return 0
    }

  2. #2
    Still A Registered User DISGUISED's Avatar
    Join Date
    Aug 2001
    Posts
    499
    Here take a look at this simple class I just coded really quickly for you. This may help you to see some of the mistakes you are making.

    Code:
    #include <iostream.h> 
    class Person 
    { 
    private: 
    	int age; 
    	float weight; 
    public: 
    	Person(){}; 
    	Person(int x, float w){age = x; weight = w;} 
    	void getData()
    	{ 
    		cout<<"Enter Age:";    cin>>age; 
    		cout<<"Enter Weight:"; cin>>weight;
    	} 
    	void showData() 
    	{ 
    		cout<<"Age:"<<age<<endl; 
    		cout<<"Weight:"<<weight<<endl; 
    	} 
    };
    int main() 
    { 
    	{ 
    		Person Disguised(22,185.5);//call to constructor with arguments
    		Person Dis_guised; //call to default constructor
    		
    		Dis_guised.getData();//member function call by object of class 
    		Disguised.showData();//using the dot operator
    		Dis_guised.showData(); 
    		
    	} 
    	return 0; 
    }

  3. #3
    learner
    Guest
    Thanks I will work on it!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Class design problem
    By h3ro in forum C++ Programming
    Replies: 10
    Last Post: 12-19-2008, 09:10 AM
  2. deriving classes
    By l2u in forum C++ Programming
    Replies: 12
    Last Post: 01-15-2007, 05:01 PM
  3. Replies: 8
    Last Post: 10-02-2005, 12:27 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. C program for Class --- DUE TODAY!!! AHHHH
    By Fr0st2k in forum C Programming
    Replies: 6
    Last Post: 09-22-2004, 03:10 PM