|
ya you are right, lets wait for some expert for some help
|
|
|
|
|
I'm in no way an expert on templates, but since nobody else have found a solution I'll give it a try.
I don't see any place where you tell the compiler what TxFunction is to be instantiated to. To be a pointer to a CxClass member taking an int parameter returning void it should be
<br />
void (CxClass::*)(int)<br />
so perhaps you should call UserFunction as
<br />
obj.m_xObject.UserFunction<void (CxClass::*)(int)>(CxClass::Foo)<br />
(i would make a typedef of the member function pointer type!)
I haven't tried it so I have no idea if it will work.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
How can i get a refrence to the only created object of class X derived from CFormView?
I want to use public members of class X outside the class (from another CView derived class).
Thanks a lot
|
|
|
|
|
CMainFrame * fram=(CMainFrame*)AfxGetMainWnd()
CMyDocument *doc=fram->GetActiveDocument();
POSITION pos = doc->GetFirstViewPosition();
while (pos != NULL)
{
CMyScrolView* pView = doc->GetNextView(pos);
}
|
|
|
|
|
nothing got in my head can u write some words.
My application is a single document the splitter pane.
|
|
|
|
|
Allow me to elaborate:
CMainFrame * fram=(CMainFrame*)AfxGetMainWnd();
CMyDocument *doc=fram->GetActiveDocument();
POSITION pos = doc->GetFirstViewPosition();
while (pos != NULL)
{
CView* pView = doc->GetNextView(pos);
if (pView->IsKindOf(RUNTIME_CLASS(CYourDerivedViewClass))) {
CYourDerivedViewClass* pYour = (CYourDerivedViewClass*)pView;
pYour->TheFunctionInQuestion();
}
}
But this makes your interface between the view classes dependent on implementation, and that's generally a bad idea. Instead I suggest you send private windows messages (or even registered ones) between you views. In CYourDerivedViewClass you can call the member function from the message handler, in this way the implementation stays in CYourDerivedViewClass. Much safer, much more clean.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
-- modified at 9:07 Friday 30th September, 2005
|
|
|
|
|
What is virtual function? Where and how can i use this concept?
|
|
|
|
|
A virtual function is used when you use polymorphism. Let's take an example to make things clear.
Suppose you have two classes:
class Base<br />
{<br />
virtual void Test();<br />
}<br />
<br />
class Child : public Base<br />
{<br />
virtual void Test();<br />
}
So in this case, the Child class inherits from Base class. The Test function has been redefined in Child classes ans is virtual (you don't need to specify virtual again in the Child class).
Virtual functions are usefull when using pointers:
Base* pPtr = new Child;<br />
....<br />
....<br />
pPtr->Test();
In that case, even if the type of the object is CBase*, the funcion that will be called will be the one of the Child class. It is very usefull when you have different that inherits from the same base class. You can redefine in each a virtual function that will do something adapted for the class itself. Thus, you can store all these pointers in a table (containing pointers to the base class) and use their 'redefined' functions.
|
|
|
|
|
class A
{
virtual testA(){}
}
class B: public A
{
virtual testB(){}
}
B b;
the question is which is true below:
1. b has 1 vptr in its A sub object, the vtbl is enlarged from A's vtbl
2. b has 2 vptrs,one in A sub object, one in B sub object, vtbl maintains its size
-- modified at 5:15 Thursday 29th September, 2005
|
|
|
|
|
1 is correct. However, A's vtable and B's vtable are different, although in this case the first entry in both tables will be the same (&A:testA). The first four bytes (in VC++6.0 at least) of the classes are the vtable ptr; in A it will point to A's vtable, in B it will point to B's vtable. That's how an A-ptr pointing to a B-object will know how to call B's version of an overloaded virtual function and not A's version.
If we expand on your example so the definitions are:
class A
{
virtual testA();
testA2();
}
class B:public A
{
virtual testA();
virtual testB();
testA2();
testB2();
}
then the object layout and the results of calling the members will be:
A: vptr ---> &A::testA
B: vptr ---> &B::testA()
&B::testB()
A a;
B b;
A* ab=&b
a.testA()
a.testA2()
b.testA()
b.testA2()
b.testB()
b.testB2()
ab->testA()
ab->testA2()
ab->testB()
ab->testB2()
Hope this clarifies it.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
For C#, the declaration of the byte is as below:
public byte[] Header_byte = {0x10,0x00};
public byte[] DataLength_byte;
But I don't know how to declare bytes in visual c++
|
|
|
|
|
If you wan't bytes (8 bits), I suggest you use unsigned char
unsigned char Header_byte[] = {0x10,0x00};
unsigned char DataLength_byte[];
or
unsigned char *DataLength_byte;
|
|
|
|
|
When I use what you suggest,it got error below:
error C2146: syntax error : missing ';' before identifier 'Header_byte'
error C2377: 'byte' : redefinition;; typedef cannot be overloaded with any other symbol
fatal error C1004: unexpected end of file found
|
|
|
|
|
Hello. I just compiled it.
This works:
unsigned char Header_byte[] = {0x10,0x00};
unsigned char *DataLength_byte2;
This one doesn't due to "Unknown datasize":
unsigned char DataLength_byte[];
|
|
|
|
|
i give up... he'd better learn C++ first !
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
read what the compilers tells you... it is clear enough.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
C# bytes are .NET framework type. C++ don't have them.
in C/C++, you can use char instead...
char Header_byte[] = {0x10, 0x00};
char DataLength_byte[];
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
For VC++ declaration of byte is
byte buf[]={0x10,0x00};
I have used it in my MFC application
and works fine .
Locgically it is same as "unsinged char".
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hi,
I have encountered compiler error C2504 during compilation of a xerces based app.
There is a header file called Filterresult.h which defines a generalization of DOMNodeFilter
#pragma message("DOMNodeFilter used in Filterresult.h")
class CFilterresult : public DOMNodeFilter
{
public:
virtual short acceptNode(DOMNode const * n) const;
CFilterresult();
virtual ~CFilterresult();
};
The xerces-Header-Files I included into stdafx.h and stdafx.h is always included exactly before Filterresult.h.
But the VC++ compiler is complaining "C2504 .. DOMNodeFilter has never been defined"
Consequently I put pragma message() into **all** Header-Files which declare DOMNodeFilter and also in the header file which defines that class. I would have expected to see, that "DOMNodeFilter used in Filterresult.h" appears before the message "DOMNodeFilter defined". But this is not true..
StdAfx.cpp
class DOMNodeFilter declared in DOMDocumentTraversal.hpp
class DOMNodeFilter declared in DOMDocument.hpp
DOMNodeFilter defined in DOMNodeFilter.hpp
Kompilierung läuft...
domparser.cpp
DOMNodeFilter used in Filterresult.h
d:\tests\xercesdomparser\domparser\filterresult.h(22) : error C2504: 'DOMNodeFilter' : Basisklasse undefiniert
Best regards
Werner
|
|
|
|
|
Just a stupid question: in your Filterresult.h file, did you include either stdafx.h or DOMNodeFilter.hpp ?
|
|
|
|
|
Hi Cedric,
I modified Filterresult.h to include DOMNodeFilter.hpp. I thought this was not necessary because I had included stdafx.h always before filterresult.h in the cpp files (I feel this might have been a wrong assumption). I modified filterresult and included a pragma message("already included") into domnodefilter.h.
#if !defined(AFX_FILTERRESULT_H__D3EED92D_3C92_473B_8382_30ED607DBEEB__INCLUDED_)<br />
#define AFX_FILTERRESULT_H__D3EED92D_3C92_473B_8382_30ED607DBEEB__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
#pragma message("DOMNodeFilter used in Filterresult.h")<br />
<br />
#include <xercesc/dom/DOMNodeFilter.hpp><br />
<br />
class CFilterresult : public DOMNodeFilter <br />
{<br />
public:<br />
virtual short acceptNode(DOMNode const * n) const;<br />
CFilterresult();<br />
virtual ~CFilterresult();<br />
<br />
};<br />
<br />
#endif // !defined(AFX_FILTERRESULT_H__D3EED92D_3C92_473B_8382_30ED607DBEEB__INCLUDED_)
well the output now is still not satisfying..
Kompilierung läuft...
StdAfx.cpp
Kompilierung läuft...
domparser.cpp
class DOMNodeFilter declared in DOMDocumentTraversal.hpp
class DOMNodeFilter declared in DOMDocument.hpp
DOMNodeFilter defined in DOMNodeFilter.hpp
DOMNodeFilter.h already included
DOMNodeFilter.h already included
DOMNodeFilter.h already included
DOMNodeFilter used in Filterresult.h
DOMNodeFilter.h already included
d:\tests\xercesdomparser\domparser\filterresult.h(17) : error C2504: 'DOMNodeFilter' : Basisklasse undefiniert
|
|
|
|
|
please note.. the code section above is missing the target of the include, which is actually
#include <xercesc/dom/DOMNodeFilter.hpp>
thanks
regards
|
|
|
|
|
Sorry, I didn't have much experience in using namespaces:
DOMNodeFilter is defined within the Xerces-Namespace, which has to be referred to by the macro
XERCES_CPP_NAMESPACE_USE.
It was enough to include that macro either within Filterresult.h or before the statement
#include Filterresult.h
regards Werner
|
|
|
|
|
hi,when we speek in Microphone (during chatting)some binary data is stored in the RAM.can any one tell me the way through which i can access those bytes. i will be very thankful to u.
|
|
|
|