-
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
}
-
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;
}
-
Thanks I will work on it!