|
Because it is not necessary to use virtual tables just to make simple job Just for one function <pre>virtual int& GetID();</pre> There are more ways how to do this but I'd like to use clean solution.
I have solution with templates for this but it is using extra class and multiple inheritance so I don't like it.
This could be useful for me also in future for different purposes so I'd like to know
|
|
|
|
|
rrrado wrote: Because it is not necessary to use virtual tables just to make simple job Smile Just for one function
virtual int& GetID();
Since this is your point of view, why do you ask for a 'clean solution'?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
How about just presuming the existence of accessor functions in the parent - I've defined a macro to help reduce the amount of typing:
template <class T> class DRecord
{
void DoReset() { static_cast<T*>(this)->SetID(0); }
};
#define DEFINE_ID_FIELD(ID_NAME) \
int NAME;
void SetID(int value) { NAME = value; }
int GetID(int value) const { return NAME; }
class A : public DRecord<A>
{
DEFINE_ID_FIELD(A_XXX)
};
As an aside - are you aware of the OLE DB consumer templates[^] - they're templated database wrappers...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you for idea, I was thinking about it and haven't realized that I don't need virtual accessors for this unless I saw your code.
I don't know OLE DB templates, thank you for tip. I'm using sqlite so I guess I cannot use them but maybe there will be some good point in their architecture.
|
|
|
|
|
rrrado wrote: I don't know OLE DB templates, thank you for tip. I'm using sqlite so I guess I cannot use them...
I wouldn't bet on it - OLE DB Provider for SQLite[^]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
i'm in an exam. and that's the question. i'vw 2 hours to answer it. thank you.
1. Write a class shape with a constructor that takes no parameters and outputs the message created a shape. The class should have two data members, area and perimeter. Write a main function to test the class by creating an object of the class shape.
|
|
|
|
|
Please tell us where you are stuck. We can help you out.
|
|
|
|
|
Try to code it instead of wasting time on forums.
BTW it should take, at least 10 minutes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Wouldn't this be called cheating and more so, cheating yourself.
on another note somethings should be like this:
class shape
{
//data member variables here
public:
// constructor here printing that a shape is created.
};
and you didn't tell what is the data type for area and perimeter and how are they to be used. otherwise why do you need these two?
I am providing the least of the information. The rest is up to you
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Hi,
I googled around a lot and found basically two ways to render contents to a directX device.
The first way is to render directly to the device (that's what I call it ):
<br />
IDirect3DDevice9* pDevice;
pDevice->Clear();<br />
pDevice->BeginScene();<br />
<br />
HRESULT hResult = pDevice->DrawPrimitiveUP( );<br />
<br />
pDevice->EndScene();<br />
pDevice->Present();<br />
The second way I found is to render first to a surface and then the complete surface at once to the device:
<br />
IDirect3DDevice9* pDevice;
<br />
CSurface* pBackBuffer;
ID3DXRenderToSurface* pRenderTarget;
pRenderTarget->BeginScene(pSurface, 0);<br />
pDevice->SetTexture(0); <br />
pDevice->DrawPrimitiveUP( );<br />
pRenderTarget->EndScene(D3DTEXF_NONE);<br />
<br />
pDevice->Clear();<br />
pDevice->BeginScene();<br />
pDevice->SetTexture(pTexture);<br />
pDevice->DrawPrimitiveUP( );
pDevice->EndScene();<br />
pDevice->Present();<br />
---------------------
My question now is:
What benefits do I get from the second approach? Is it faster? For me it looks like I just put one more step in the row. Is there less flickering? Do I have more possibilities with the second approach?
My second question is:
I found a forum-thread where they told that it is no advised to render directly into a surface, because it would destroy performance. The thread applied to managed directx. Is this true? Does it apply to unmanaged DirectX also? Is it slower to render to surfaces?
Thanks in advance
Snowprog
|
|
|
|
|
Snowprog77 wrote: My question now is:
What benefits do I get from the second approach?
Snowprog77 wrote: For me it looks like I just put one more step in the row. Is there less flickering?
Yes, AFAIK.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Snowprog77 wrote: What benefits do I get from the second approach? Is it faster? For me it looks like I just put one more step in the row. Is there less flickering?
Yes - graphics hardware has highly optimised bit-blit operations, which is precisely what's used to move the off-screen surface to the device.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
dear admin
I happened the question ,occur error about 0x000006BA: RPC can not used when I debuged with vc++ program of window xp professional ,as it.
First-chance exception at 0x7c812a6b in ulogin.exe: 0x000006BA: RPC 服务器不可用。.
would you tell me to slove it ,thank you!
|
|
|
|
|
I want to do a two aggressive color scale, but i don't know how to get the color value between two colors.
for example a red-blue color scale is: red -> pink ->light blue->blue.
Please tell me if you know it. Thank you very much!
scott
|
|
|
|
|
You got a lot to learn about colors. Read some stuff about RGB-Values and macros.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
|
What is an 'aggressive color scale'.
Maybe this article [^] (and it's references) will help.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Colors are represented by red, Green, and blue values (RGB). To get a color between two colors, average their RGB values:
R = (R1 + R2) / 2;
G = (G1 + G2) / 2;
B = (B1 + B2) / 2;
Where color 1 is (R1, G1, B1), color 2 is (R2, G2, B2) and the between color is (R, G, B).
|
|
|
|
|
hi
i have one view base class is CFormView.when i Resize my application. View size also changing , Which is expected but all the controls in are not visible. Here I need scroll bar for this view in this situation to view all controls. In resource view I enabled vertical and horizontal scrolls but its not working. please help me how to do it..
|
|
|
|
|
Yeah - you need to handle scrolling yourself. You need to:
- When the view is resized, work out if it's big enough to display all the controls. If it is, then disable the scroll bars. If it isn't, then you need to use
SetScrollInfo [^] to tell the scrollbars how to display themselves. - You need to add OnVScroll and/or OnHScroll handlers to deal with scroll messages. Use SetScrollPos[^] and ScrollWindow[^] to tell the view about the scrollbar parameters so it can work out which bit of the form should be displayed
Yeah, it's a pain. Microsoft do supply a CScrollView...but that inherits from CView, as does CFormView - and MFC is a bit backward when it comes to OOP.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
I am compiling the legacy code in VS.Net 2008 64 bit platform. I am getting the above error in the following line
static HRESULT copy(destination_type* pTo , const int source_type* pFrom)
how to resolve the above error?
Please help me
Regards
|
|
|
|
|
What are destination_type and source_type meant to be?
Also - "const int source_type* pFrom" looks wrong no matter what source_type is (unless it is nothing)
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
This is the definition
template <class MapType, class DestinationType = MapType::referent_type>
and source type is defined as
typename MapType::value_type source_type;
what is wrong here?
|
|
|
|
|
const int source_type* pFrom
You have two types in that parameter declaration. Let us say that source_type is std::string - that translates to
const int std::string* pFrom
That doesn't make sense, now, does it?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|