|
I guess you are referring the object slicing issue in c++ while passing class objects as by value in function parameters.
This issue happens when we are passing a derived class object as by value parameter to a function and there if we receive it into a variable of a base class type.
In this scenario generally, a derived class object will have more data members than its base or ancestor class objects, so the compiler, without complaining, simply "slices off" the extra data members of the derived class object and uses only the members inherited from the base or ancestor class for the base or ancestor class variable. However, when references or pointers to base arguments are used, this "slicing" does not occur, which is one of the reasons that references and pointers are so important in C++ OOP.
cheers mil10.
|
|
|
|
|
Thank you mil, You clarified my assumptions in Object Slicing.
It is helped me to understand the code i have.
|
|
|
|
|
I NEED B TREE INSERTION AND DELATION CODE.PLE HELP THANKS
WAQAS
|
|
|
|
|
Ok, so Google for it.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
void MyFun()
{
Fun1();
FunSendingMessage();
.........code
}
void MessageHandlerFun()
{
.........code
.........code
}
Thank you very much!!!
-------------------
I am learning C++ and English
|
|
|
|
|
That's what will happen automatically if you use the SendMessage API to send the message.
Steve
|
|
|
|
|
the program control will run MyFun()
then it will call FunSendingMessage(), since it is using SendMessage, the main function MyFun will not regain control until the function MessageHandleFun() will finish and return....
so basically you don't have to do anything
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Hi!
In my project, I am importing a class which contains a STL map as a member from a DLL (not written by me). My goal is to inherit a class and then add function that needs to access the map directly, i.e. there are no functions that return reference to this map so I could avoid map's protected scope. Class already contains similar functions that work properly.
(To demistify things a bit, the class is used for communication and uses TCP protocol via its own functions. I would like to inherit from the class and override some of the functions to make them use UDP protocol).
The problem is when my function is trying to access the map (at run-time), the whole thing crashes. Using VS2005 debugger, I have detected that in my function, the map object seems to be invalid (it still appears to be of map type but its size and content do not make any sense). If I try to log the content of the map (instead of accessing it) using functions which are already in the class, everything passes OK.
What puzzles me is that I managed to achieve the same thing a few months ago in another project, but I can't retrace my steps or reproduce the same result. I never changed and/or recompiled the library.
TIA for your help (and I apologize for the length)
Marko
P.S. Class header file looks in short like this:
#include ...
class OriginalClass {
public:
...
_declspec(dllimport) Function();
...
protected:
map<string, unsigned="" int=""> myMap;
};
|
|
|
|
|
mbudisic wrote: P.S. Class header file looks in short like this:
#include ...
class OriginalClass {
public:
...
_declspec(dllimport) Function();
...
protected:
map myMap;
};
You should export/import the whole class with the usual macros.
|
|
|
|
|
Yes, but as I stated, I didn't write the library and yet managed to somehow work around it (by some magic, apparently, since I can not reproduce it). What good is having protected members in such a class, anyway?
Thank you for your reply.
Marko Budisic
|
|
|
|
|
Hi!
I'm using SetViewportExt, SetWindowExt to zoom a CImage picture. My problem is with zoom out. Let's say I want to zoom out to 50%. The image resulted is full of noises. I also used StrechBlt and got a better result but I would like to implement zoom features using SetViewportExt and SetWindowExt, and have the same result for zoom out like StrechBlt.
Can anyone help me?
Thnks.
Bogdan C
|
|
|
|
|
Hi all,
I need to repaint a child window in my MDI application, which need not be active. If use MDIGetActive and MDINext to traverse the children, I am able to see a flickering. When the desired child is getting repainted, I am calling MDIActivate(pFirstChild) to reset the active child.
I'd like to do this using CDocument's GetFirstViewPosition and GetNextView. Kindly check the following code snippet: The problem is, the while loop executes exactly once, even though I open three child windows.
pos = pDocument->GetFirstViewPosition() ;<br />
<br />
while(pos)<br />
{<br />
CMyView *pView = (CMyView *) pDocument->GetNextView(pos) ;<br />
<br />
if(pView->m_childNum == m_usChildNo)<br />
{<br />
pView->SetDisplayData() ;<br />
pView->Invalidate() ;<br />
break ;<br />
}<br />
}
Where am I wrong?
Thanks in advance,
Sarvan AL
-- modified at 7:13 Monday 17th April, 2006
|
|
|
|
|
I can see a break in the if condition.maybe that is why the loop occurs once?
try to debug it
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Hi Sarvan AL,
Why you use break in your code?
|
|
|
|
|
Hi WhiteSky,
Let me explain the scenario in detail.
I have one CScrollView derived class (Type-1) and Four CFormView derived classes (Type-2). I open three objects of Type-1. From the menu, I am changing the font and like to repaint all three windows. I have only one document. The GetNextView in the while loop makes the -pos- parameter NULL when I trace.
I open the child windows using the following function, with document name "MyView".
void CProj5App::OpenForm(CString strDocName)<br />
{<br />
CString strDoc ;<br />
POSITION pos = GetFirstDocTemplatePosition() ;<br />
<br />
while(pos)<br />
{<br />
CDocTemplate *pDoc = GetNextDocTemplate(pos) ;<br />
pDoc->GetDocString(strDoc, CDocTemplate::docName) ;<br />
<br />
if(strDocName.CompareNoCase(strDoc) == 0)<br />
{<br />
pDoc->OpenDocumentFile(NULL) ;<br />
break ;<br />
}<br />
}<br />
}
Where I am wrong?
Thanks in advance,
Sarvan AL
|
|
|
|
|
Where's the class wizard in VC7.1 ? How can I handle events for my Dialog ? when I right click on the dialog, I dont find "add Event Handler" , I know I'm quite late to notice it. But please help me , is there any round about way to reach the wizard ?
NULL
|
|
|
|
|
|
Hi,
i want draw graph which has got time in sec on X-axis and on Y axis i have different parameter Say A,B,C..Say A in temprature B is VOlts etc..i.e for A,B,c X-axis is same Y-Axis varies , Is there example which will meet my requirement..If any thing is not clear pls let me know so that i will clarify,i am in urgent need of it.
Its very similar to diagram in below URL pls check the URL
http://www.memorytesters.com/sim2/s2_ap11.htm
James rocky
-- modified at 6:31 Monday 17th April, 2006
|
|
|
|
|
I think you are going to plot something... then you have some readings with constant time intervals, right?
Then take these values in an array (or arrays for A, B, C, etc.).
Can you do these things?
- NS -
|
|
|
|
|
Is there any sample application to implement the timing diagram concept?
|
|
|
|
|
I'm sorry. I don't have any sample with me.
- NS -
|
|
|
|
|
My problem is that when i rotate my multiline text 180 degrees , the text is rotated but the ordering of lines in the text is wrong as the first line comes as last and last line comes as first(for eg. if i have two lines line1 & line2 then after rotation line2 is displayed and below it line1 is diaplayed).I have passed the DT_WORDBREAK as parameter to the CDC drawtext function to handle word wrapping.
Is ther any other way to handle rotation of multiline text?
Kindly let me know
|
|
|
|
|
The following example shows how to rotate text at any angle (doesn't work on 95/98/ME). It renders text at (50, 50) rotated 30 degress clockwise.
--------------------------------------
CPaintDC dc(this);
int OldMode = SetGraphicsMode(dc.m_hDC, GM_ADVANCED);
static const double pi = 4.0*atan(1.0);
static const double angle = 30.0*(pi/180.0);
static const XFORM xf = {cos(angle), sin(angle),
-sin(angle), cos(angle),
0, 0};
SetWorldTransform(dc.m_hDC, &xf);
CRect rcClient;
GetClientRect(&rcClient);
rcClient += CPoint(50, 50);
dc.DrawText(_T("Hello\nThere"), -1, &rcClient, 0);
SetGraphicsMode(dc.m_hDC, OldMode);
--------------------------------------
Steve
|
|
|
|
|
hi all,
plz tell me how to draw colored button in mfc
thanks in advanced
Rahul here
|
|
|
|
|
You have to use ownerdraw...
- NS -
|
|
|
|