|
In Other words, When the First Step of construction takes place, we are constructing the Root Class, which has the V-Table of the Root Class.(No Idea yet of Your Classes' V-Table) If the language allowed you to declare a Virtual constructor, it would be in the V-Table of your final class, and only be available AFTER your class was constructed. Now that would be realy like mustard after the meal. Ofcourse someone could write a compiler which takes account of these things. The language it compiles would no longer be cpp though.
The long and short of it is therefore, If you need a Virtual Constructor, you are organising your code wrong. Look at your code and try again.
regards
LateNightsInNewry
|
|
|
|
|
LateNightsInNewry wrote: The long and short of it is therefore, If you need a Virtual Constructor, you are organising your code wrong. Look at your code and try again.
Even if you need one, C++ is not going to let you have one. That would be a compile time error blunder.
The greater the difficulty, the greater the glory.
- Marcus Tullius Cicero
|
|
|
|
|
Hi all
In my project i am displaying a 3d model ( created by the marching cube
algoritham) composed of triangles. This model is constructed from the 2d images slices.
Now i need to select some polygons from that model. For example user drag
drop and created a bounding box , and i want to get those polygons inside that bounding box.It should be fast enough (At least don't take minutes ).
I think Opengl Picking may not work. because i can't name each polygon a unique name , because i have millions of polygons. So if i do that it may leads to statk overflow of name stack(glPushName).
Any idea will be Greatly appreciated.
Thanks in advance
krishnan
If u can Dream... U can do it
|
|
|
|
|
krishnadevank wrote: and i want to get those polygons inside that bounding box.It should be fast enough (At least don't take minutes ).
Several ways jump out. First You have the zone, you can render one more frame with a clip-buffer which isolates the polygons individually within the zones. You can identify which ones by coloring each differently, or split the work out, by doing so in each 2D image slice.
Remember that even at 20-60hz you can take a frame to do some work and then get back to the job of drawing. Multi-rendering methods make great shortcuts. You can also use the obscure test from the ARB and setup an obscuring object everywhere except the zone of interest, and get back only those triangles within the zone. You can also do the same test as you draw, using a multi-render cycle you can check the result of the projection and write to see if it should be clipped or kept with a stencil buffer and test the triangles you need.
Once again you can brute force it, or break it down, test slice by slice to see if any triangles are in the zone on cycle 0, then test those triangles in each slice one at a time for zone proximity, cycle 1+. Within a couple of frame cycles you can find all the triangles you need.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Hi
I am trying to pass by reference a variable. Below is the code.
In the class def I have
<br />
void OnLoseFocusDate( Date &jdtDate);<br />
and in the src file I have
<br />
<br />
void CEQSLowerInterestLeg::OnLoseFocusDate( Date &jdtDate)<br />
{<br />
<br />
if( jdtDate != Util::grdtNull) <br />
{<br />
Date adjust_date( jdtDate );<br />
const CCalendar *calendar = CHolidayMgr::GetInstance().GetEquityLegPaymentHoliday();<br />
if (calendar)<br />
{<br />
adjust_date = calendar->BusinessDayIf(adjust_date, (EnBusDayConvention)m_jcmBDC.GetSelectedObjectID(), &ToolUtils::PromptForBusinessDay);<br />
<br />
jdtDate = adjust_date;<br />
<br />
}<br />
}<br />
}
<br />
with the function call being
<br />
<br />
OnLoseFocusDate(m_jdtTerminationDate.GetValue());<br />
<br />
where GetValue()
is defined as
<br />
<br />
Date NewDate::GetValue(void)<br />
{<br />
if (::IsWindow(this->m_hWnd) && GetFocus() == this )<br />
{<br />
if( m_dateFormat == shortFormat )<br />
{<br />
SetError(!IsValid());<br />
}<br />
}<br />
<br />
return m_value;<br />
<br />
<br />
}<br />
<br />
and m_value is defined as Date m_value;
The error I am getting is
<br />
<br />
error C2220: warning treated as error - no object file generated<br />
C:\viewstr\ptp6970-DateChange\Swaps\ptp\src\eqslowerinterestleg.cpp(2039) : warning C4239: nonstandard extension used : 'argument' : conversion from 'class Date' to 'class Date &'<br />
A reference that is not to 'const' cannot be bound to a non-lvalue<br />
I dont understand why I get this error and I dont believe the solution is to pass in by const reference since I modify the argument in the function. Can someone please explain why I get this error and a solution?
I have found that if I do
<br />
Date xx = m_jdtTerminationDate.GetValue();<br />
OnLoseFocusDate(xx);<br />
<br />
then it is ok but I dont understand the difference between the 2 methods.
Many thanks !
|
|
|
|
|
The problem is that when you return something from a function (for example your GetValue function), a copy of your object will be made (you don't return the object itself but a copy). So in your case, passing it by reference would mean that the function (OnLoseFocusDate) will probably want to modify it. But in your case it is totally useless because the object is lost after the function is called (so, the modifications are lost).
One way to do it is to return a reference to your object in the GetValue function:
Date& NewDate::GetValue(void)<br />
{<br />
if (::IsWindow(this->m_hWnd) && GetFocus() == this )<br />
{<br />
if( m_dateFormat == shortFormat )<br />
{<br />
SetError(!IsValid());<br />
}<br />
}<br />
<br />
return m_value;<br />
<br />
<br />
}<br />
But honnestly, I don't really find this very elegant...
|
|
|
|
|
minkowski wrote: Date xx = m_jdtTerminationDate.GetValue();
OnLoseFocusDate(xx);
A Reference is in effect, a Compiler Generated and Guaranteed Pointer. Unlike Ordinary Poiners, they cannot be NULL, and in most cases, when you try to do something daft, the compiler will object. This happened in this case! A Reference implicitly points to a value in memory. The result of a Function is essentially not a value in memory, so the compiler objects, It is WRONG!
Your Second attempt works, because the reference is an implicit pointer to xx
LateNightsInNewry
|
|
|
|
|
hi,
I want to change the CLSID for an existng class .That is,i want to use the features of a class by giving different name and different CLSID to it.In which application .rgs file is generated.
Thanks in advance
Siddharth
|
|
|
|
|
siddharthsan wrote: I want to change the CLSID for an existng class .
This is bad idea. Why you want to do this ?
siddharthsan wrote: That is,i want to use the features of a class by giving different name and different CLSID to it
What is your problem then ?
|
|
|
|
|
Hello, tell as it is possible to catch occurrence of windows in the another's program, and then to block their occurrence. If it is possible an example. Thank.
-- Am be back --
|
|
|
|
|
Not sure what you want as your post is not very clear but it sounds like you may want to setup a WH_CBT hook.
Look up SetWindowsHookEx() in MSDN, payiny attention to the WH_CBT hook ID and the CBTProc hook procedure. Also see this article[^] on using global hooks.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Hi
I am reading Linkers and Loaders book. It says: "Linker binds more abstract names to more concrete names, which permits programmers to write code using the more abstract names"
I tried a piece of code:
<br />
#include <iostream><br />
using namespace std;<br />
<br />
int main()<br />
{ int x = 0; <br />
foo(x);<br />
return 0;<br />
}<br />
This code tries to use foo function which is not defined anywhere. So I expect VS2005 gives me linker error but it gives me compile-time error.
Why doesnt it give me linker-time error? How must i change code so it gives me linking-time error?
Thanks
|
|
|
|
|
the linker works AFTER the compiler, so if the later cannot compiler, why do you bother ?
you will have a linker error if you define the function in another .cpp file, but don't provide it then
the compiler expects the declaration of a function only. the linker needs the whole body, so if you don't declare the function, you'll face a compiler error
|
|
|
|
|
Because your compiler first check if the function is declared somewhere. It is needed, that's why you need to include files in your cpp files.
What you could do is abuse the compiler in this way: declare the function (provide a functino prototype) but don't define it (no function body).
#include
using namespace std;
void foo(int);
int main()
{ int x = 0;
foo(x);
return 0;
}
In this way the compiler sees that the function exists so it won't complain. But the linker will complain because you didn't provide a body.
|
|
|
|
|
In order to see the linker error all you have to do is
declaring your function without it's definition like this:
<br />
#include <br />
using namespace std;<br />
<br />
void foo(int x);
<br />
int main()<br />
{ int x = 0; <br />
foo(x);
return 0;<br />
}<br />
<br />
|
|
|
|
|
How to remove this 2px line on the top of ReBar control? I've found a RBS_BANDBORDERS style using spy++ but removing this style does not help (neither by calling CReBar::Create(this,0) nor by CReBar::ModifyStyle(RBS_BANDBORDERS,0) - even without this style control still has a line on the top.
Any idea how to disable this line?
Thanks in advance!
|
|
|
|
|
I am having some difficulty passing an array. If someone can shed some light here, I would appreciate it greatly.
void testFunction(int, int, bool, int, int, int [ ], char);
<br />
void testProgram()<br />
{<br />
int testCaseArray1[ 9 ] = { 500, 250, 375, 438, 469, 485, 493, 497, 499 };<br />
char choice1 = 'Y';<br />
<br />
testFunction(0, 0, false, 499, 9, testCaseArray1, 'Y');<br />
}<br />
<br />
void testFunction(int myGuess1, int myGuessCount1, bool myBool, int myInt1, int myInt2, int myArray[ ], char myChar='Y')<br />
{<br />
int num1 = myInt1;<br />
int arraySize1 = myInt2;<br />
int guess1 = myGuess1;<br />
int testCaseArray1[ arraySize1 ];
int guessCount1 = 0;<br />
char choice1 = myChar;<br />
bool correctAnswer1 = myBool;
|
|
|
|
|
You should declare your function this way:
void testFunction(int, int, bool, int, int, int*, char);
There is another thing wrong in your program. This line:
int testCaseArray1[ arraySize1 ];
You cannot declare an array this way (arraySize1 is not a constant). You need to dynamically allocate your array:
int* testCaseArray1 = new int[arraySize1];
And don't forget to delete it when you don't need it anymore.
I would suggest that you take a look at container classes from the STL. It might be hard to understand for a beginner but it solves a lot of problems (memory management and so on).
|
|
|
|
|
OK, but where is your question?
ericelysia wrote: int testCaseArray1[ arraySize1 ];
That won't work because you have to initialize your array with constant expressions. So the array should be defined like this: int testCaseArray1[5];
If you want to initialize different size arrays you have to use
new operand with pointer:
int mySize;<br />
mySize=5;<br />
int *testCaseArray1=new int[mySize]; . When the array initialized with new operand is no longer needed you have to delete it with delete operand: delete [] testCaseArray1;
|
|
|
|
|
I have created a package for my project using visual studio installer , package created successfully. While creating package I have added all required files from dll and also from exe, related files.
I am trying to install the package in a system which does not have Visual Studio,
While I am installing the package I am getting error
Error 1904: module c:\ programming files \ DemoSoft\Demo.dll failed to register HRESULT 2147024770 , contact your support personal
|
|
|
|
|
Can anyone give Video tutorial of VS2005 IDE, VC++ - MFC-Win32- Application tutorial.
|
|
|
|
|
This is a very broad subject that simply cannot covered in a single post. The best way for you to learn is either learn by yourself or buy a good book on the subject (or find free tutorials on the web).
|
|
|
|
|
Cedric,
I am familiar with VC 6.0-IDE, MFC, Win32 etc.
What i am looking for is some good video which explain VS 2005 IDE and using MFC, ATL & other new stuffs of VS 2005
|
|
|
|
|
No such video can explain you each and everything that is new. Buy a book. Nothing else will help you.
Never injure a friend, even in jest.
- Marcus Tullius Cicero
|
|
|
|
|
If you are familiar with VC6 and the MFC, then you shouldn't have troubles to move to VS 2005. There are some slight changes in the MFC but they are minor. And the IDE is not very difficult to understand once you understand VC6.
|
|
|
|