Class Item (Int Code Float Price Public: Void Getdata (Int A, Float B) (Code A Price B ) Void Show (Cout Code Price ) )
Class Item (Int Code Float Price Public: Void Getdata (Int A, Float B) (Code A Price B ) Void Show (Cout Code Price ) )
Class item { int code; float price; public: void getdata(int a,float b) { code=a; price=b; } void show() { cout<<code<<price; } };
const int size=2; main() { item *p=new item[size]; item *d=p; int x,i; float y; for(i=0;i<size;i++) { cout<<input code and price; cin>>x>>y; p->getdata(x,y); p++; } for(i=0;i<size;i++) { d ->show(); d ++; } }
class BC { public:
{
cout<<b; } }; class DC:public BC {: public: int d; void show() { cout<<b; cout<<d; }
};
//We can define a pointer to the member m as follows: int A::*ip=&A::m; Cout<<a*ip; //a is object
Ip pointer is created thus acts like a class member in that it must be invoked with a class object A::* means pointer to member of A class &A::m means the address of the m member of A class Int *p=&m//wont work Bcz m is not simply int type data.it has meaning only when it is associated with class
Class x { public: int a; void f(int b) { cout<<b; } }; main() { int x::*p=&x::a; //declare to pointer member void(x::*pi)(int)=&x::f; //declare pointer to member function x c; //create object of class c.*p=10; cout<<value of a is<<c.*p; (c.*pi)(20); //call member function }
o/p: Value of a is 10 20
Memory leak
A memory leak occurs when a piece of memory that was previously allocated by a programmer is not properly deallocated by the programmer
Even though that memory is no longer in use by the program,it is still reserved and the piece of memory cannot be used by the programm until it is properly deallocated by the programmer
Char *p,*q p=new char[10000]; q=new char[50000];