You are on page 1of 3

programs

Program to find length of line using default


constructor
• #include<iostream> using namespace std; class line { public: void
setlength(double line); double getlength(void); line(); private:
double length; }l; line::line() { cout<<"object is being
created:"<<endl; } void line::setlength(double line) { length=line; }
double line::getlength(void) { return length; } int main()
{ l.setlength(6.666666); cout<<"length of
line="<<l.getlength()<<endl; return 0; }
Student details
• #include<iostream> using namespace std; class student { public:
int rollno,age; string name,adr,gender; float per; void mikku();
{ cout<<"enter the student name:"; cin>>name;
cout<<"enter the roll no:"; cin>>rollno; cout<<"enter the
gender:"; cin>>gender; cout<<"enter the address:";
cin>>adr; } void kukku(); { cout<<"" } }m;

You might also like