|
How are you using Items? It looks to me like the compiler and linker are seeing Items as a global symbol (i.e. not a class member).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
but in delphi it is used
delphi code is this
TClipCollection = class(TCollection)
private
function GetItem(Index: Integer): TClipItem;
procedure SetItem(Index: Integer; const Value: TClipItem);
public
constructor Create;
property Items[Index: Integer]: TClipItem read GetItem write SetItem; default;
function Add: TClipItem;
function GetEnumerator: TClipCollectionEnumerator;
end;
you r right and when i mke the constructor of this class then i got also error
E2251 Cannot find default constructor to initialize base class 'TCollection'
then what i do for this
|
|
|
|
|
rajeshkumarrajput wrote: but in delphi it is used
Delphi is a different language than C++ - it has different rules - and anyway, I asked you how Items was used in your code - it's the use of something called Items, not the definition that's causing that error.
I suspect your GetItem/SetItem code is overriding the relevant property accessors from TCollection, so you probably need something like:
TClipItem* TClipCollection::GetItem(int index)
{
return (TClipItem*)(((TCollection*)this)->Items[index]);
} ?
rajeshkumarrajput wrote: E2251 Cannot find default constructor to initialize base class 'TCollection'
That'll be because TCollection has no default constructors - look at the documentation (C++ Builder has documentation, I presume?) and work out which constructor you should be using.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
now i am getting the error
E2297 'this' can only be used within a member function
can i send my code to solve the problem ?
|
|
|
|
|
I'd suggest you might want to learn C++ instead - that'll be more use in the long run.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
thanks Stuart Dootson
for help
|
|
|
|
|
I need to crate template class which will be generic parent of more classes containing data. Each child class defines something like item ID (different name in each class, but always int) and I need to let parent class know it's name to be able to make some operations on that.
This is pseudocode:
template <class T, ???XXX > class DRecord
{
void DoReset() { ((T*)this) -> XXX = 0; }
}
class A : public DRecord<A, ???A_XXX >
{
int A_XXX;
}
XXX is template param I need to define and use some way. I've tried to use member pointers but it didn't compile. Is it possible to define member of child class as parameter into parent class? In moment of parsing the template the member variable is not declared yet, so I'm not sure whether is it possible.
Thank you.
|
|
|
|
|
Why do you want to do that?
Could just use polimorphism, couldn't you?
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]
|
|
|
|
|
I'm creating some database wrapper, it maps tables to classes (or structures). There are some common operations I need to do on primary keys, but each table is using different PK names. I want to code common operations only once (using templates, not preprocessor macros unless necessary) and don't want to use virtual functions (it should be theoretically possible, but I don't know whether C++ templates are powerful enough for this).
It is also interesting problem for me since I'm not template expert and I'd like to learn
|
|
|
|
|
rrrado wrote: and don't want to use virtual functions
Why don't you (you know base classes practically imply this... )?
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]
|
|
|
|
|
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
|
|
|
|