T
toton
Operator overloading has a sort syntax rather than member function call
for stack based memory allocation.
like complex<int> c1,c2,c3;
c3= c1+c2;
How the same can be applied to heap based memory allocation?
like complex<int> * c1,*c2,*c3;
i still want to do something like c3 = c1+c2 ; rether than *c3 =
*c1+*c2;
can a third operator overloading be used to convert pointer to
reference?...
or is there exist some special pointer class where +,- etc wont add the
pointers itself but rather the data.
and when to use class & data both in stack , the class in stack & data
in heap (like c++ vector etc) and both class & data in heap? any
general guideline?
It seems that all of the gui classes initialize in heap ( like Button
Panel etc) or data centric classes like Image File etc.
I want something like , i have an Image class ( say TImage from borland
) which should be initialized as TImage* image=new TImage(filename); as
it creates the class at runtime in heap.
now i want to use some sorthand operator like >> to store it in a file
( opt stream) or +,- etc for image operations line
image3=image1+image2 rather than *image3 = *image1+*image2;
note i cant initialize TImage img, as it cant call default ctor which
needs filename, but that available only when user inputs it. also if i
add a default ctor then the state of the image is unknown.
In sort can any pointer trick can be performed to look a c++ heap
based class look like Java heap based class , where it internally
converts the pointer as reference , and hence everyting can be accessed
using . (dot ) operator.
thanks
abir basak
for stack based memory allocation.
like complex<int> c1,c2,c3;
c3= c1+c2;
How the same can be applied to heap based memory allocation?
like complex<int> * c1,*c2,*c3;
i still want to do something like c3 = c1+c2 ; rether than *c3 =
*c1+*c2;
can a third operator overloading be used to convert pointer to
reference?...
or is there exist some special pointer class where +,- etc wont add the
pointers itself but rather the data.
and when to use class & data both in stack , the class in stack & data
in heap (like c++ vector etc) and both class & data in heap? any
general guideline?
It seems that all of the gui classes initialize in heap ( like Button
Panel etc) or data centric classes like Image File etc.
I want something like , i have an Image class ( say TImage from borland
) which should be initialized as TImage* image=new TImage(filename); as
it creates the class at runtime in heap.
now i want to use some sorthand operator like >> to store it in a file
( opt stream) or +,- etc for image operations line
image3=image1+image2 rather than *image3 = *image1+*image2;
note i cant initialize TImage img, as it cant call default ctor which
needs filename, but that available only when user inputs it. also if i
add a default ctor then the state of the image is unknown.
In sort can any pointer trick can be performed to look a c++ heap
based class look like Java heap based class , where it internally
converts the pointer as reference , and hence everyting can be accessed
using . (dot ) operator.
thanks
abir basak