c++ saurabh shukla
c++ saurabh shukla
#include<conio.h>
#include<iostream.h>
struct book
{
int bookid;
char title[20];
float price;
void input()
{
cout<<" Enter bookid,title,and price";
cin>>bookid>>title>>price;
}
void display()
{
cout<<"\n"<<bookid<<" "<<title<<" "<<price;
};
void main()
{
clrscr();
book b1;
b1.input();
b1.display();
getch{};
}
{program}/for structure with access modifier/
#include<conio.h>
#include<iostream.h>
struct book
{
private:
int bookid;
char title[20];
float price;
void input()
{
public:
cout<<" Enter bookid,title,and price";
cin>>bookid>>title>>price;
}
void display()
{
cout<<"\n"<<bookid<<" "<<title<<" "<<price;
};
void main()
{
clrscr();
book b1;
b1.input();
b1.display();
getch{};
}
{program}/for constructor/
#include<conio.h>
class complex
{
private:
int a,b;
public:
complex()
{ cout<<"hello constructor";}
};
void main()
{
clrscr();
complex c1,c2,c3;
getch();
}
;Default constructor
; parameterized constructor