Click here to Skip to main content
15,917,062 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Translate C-Code to Csharp Pin
Sauro Viti8-Nov-10 3:31
professionalSauro Viti8-Nov-10 3:31 
GeneralRe: Translate C-Code to Csharp Pin
djfresh8-Nov-10 3:47
djfresh8-Nov-10 3:47 
AnswerRe: Translate C-Code to Csharp Pin
Sauro Viti8-Nov-10 4:07
professionalSauro Viti8-Nov-10 4:07 
GeneralRe: Translate C-Code to Csharp Pin
djfresh9-Nov-10 2:12
djfresh9-Nov-10 2:12 
AnswerRe: Translate C-Code to Csharp Pin
Luc Pattyn8-Nov-10 4:07
sitebuilderLuc Pattyn8-Nov-10 4:07 
QuestionWhy SampleGrabber->SetOneShot(FALSE) fails with video files? Pin
Chesnokov Yuriy8-Nov-10 0:12
professionalChesnokov Yuriy8-Nov-10 0:12 
Question890817 - what's wrong with clicking on a control in a dockable pane? Pin
ilostmyid28-Nov-10 0:02
professionalilostmyid28-Nov-10 0:02 
AnswerRe: 890817 - what's wrong with clicking on a control in a dockable pane? Pin
Sauro Viti8-Nov-10 1:04
professionalSauro Viti8-Nov-10 1:04 
GeneralRe: 890817 - what's wrong with clicking on a control in a dockable pane? Pin
ilostmyid28-Nov-10 1:51
professionalilostmyid28-Nov-10 1:51 
GeneralRe: 890817 - what's wrong with clicking on a control in a dockable pane? Pin
Sauro Viti8-Nov-10 2:12
professionalSauro Viti8-Nov-10 2:12 
AnswerRe: 890817 - what's wrong with clicking on a control in a dockable pane? Pin
Sauro Viti8-Nov-10 2:18
professionalSauro Viti8-Nov-10 2:18 
GeneralRe: 890817 - what's wrong with clicking on a control in a dockable pane? Pin
ilostmyid28-Nov-10 18:03
professionalilostmyid28-Nov-10 18:03 
QuestionHow to use get the image's URL from web page Pin
yu-jian6-Nov-10 6:24
yu-jian6-Nov-10 6:24 
AnswerRe: How to use get the image's URL from web page Pin
«_Superman_»6-Nov-10 6:48
professional«_Superman_»6-Nov-10 6:48 
GeneralRe: How to use get the image's URL from web page Pin
yu-jian7-Nov-10 14:55
yu-jian7-Nov-10 14:55 
GeneralRe: How to use get the image's URL from web page Pin
«_Superman_»7-Nov-10 15:26
professional«_Superman_»7-Nov-10 15:26 
GeneralRe: How to use get the image's URL from web page Pin
yu-jian7-Nov-10 16:44
yu-jian7-Nov-10 16:44 
QuestionCopying Variants Pin
softwaremonkey5-Nov-10 23:59
softwaremonkey5-Nov-10 23:59 
AnswerRe: Copying Variants Pin
softwaremonkey6-Nov-10 0:42
softwaremonkey6-Nov-10 0:42 
QuestionRegEnumValue not return the correct values Pin
Arnon A5-Nov-10 12:39
Arnon A5-Nov-10 12:39 
AnswerRe: RegEnumValue not return the correct values Pin
«_Superman_»5-Nov-10 14:41
professional«_Superman_»5-Nov-10 14:41 
AnswerRe: RegEnumValue not return the correct values Pin
krmed6-Nov-10 3:50
krmed6-Nov-10 3:50 
GeneralRe: RegEnumValue not return the correct values Pin
Arnon A7-Nov-10 21:25
Arnon A7-Nov-10 21:25 
QuestionRe: RegEnumValue not return the correct values Pin
David Crow6-Nov-10 17:58
David Crow6-Nov-10 17:58 
QuestionCompiler Error in Template Functions...? [modified] Pin
Joseph Dempsey5-Nov-10 7:41
Joseph Dempsey5-Nov-10 7:41 
I have run into a very strange error today and was wondering if anyone else has seen this. Some digging on google suggests it might be a compiler error. I've seen this on VS2008 and GCC 4.1.2.

I was able to build a test harness to repro the issue. It is below:

<pre>

#include <iostream>

class Cloneable
{
public:
template<class TYPE> TYPE* clone() const { return dynamic_cast< TYPE* > ( clone() ); }
virtual Cloneable* clone() const = 0;
};

// simple template class that defines an interface
// for cloning objects.
class X : public Cloneable
{
public:
X(int _y ) : data(_y) { }
virtual ~X() { /* DO NOTHING */ }
virtual Cloneable* clone() const { return new X(data); }

protected:
X() { /* DO NOTHING */ }
int data;
};

class Y : public X
{
public:
Y(double f, int y) : X(y), dataf(f) { /* DO NOTHING */ }
virtual ~Y() { /* DO NOTHING */ }

virtual Cloneable* clone() const { return new Y(dataf, data); }
protected:
double dataf;
};

// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

int main(int argc, char* argv[])
{
X* x = new X(1);
X* x1 = x->clone<X>();

Y* y = new Y(2.12, 4);
Y* y1 = y->clone<Y>();

delete y;
delete y1;
delete x;
delete x1;

return 0;
}
</pre>

The clone<TYPE> fails in both cases in the main function. It should cast properly. There seem to be two ways to fix this. If i move the templated function from Cloneable to X & Y it works in both cases. The other is to use clone() in the main function and dyna cast there.

A standard C cast in the templated function also doesn't work. Its like the compiler is erroneously changing the protection level on the function and then gets confused and just dumps out the error.

<pre>
1>Compiling...
1>main.cpp
1>.\main.cpp(40) : error C2275: 'X' : illegal use of this type as an expression
1> .\main.cpp(12) : see declaration of 'X'
1>.\main.cpp(40) : error C2059: syntax error : ')'
1>.\main.cpp(43) : error C2275: 'Y' : illegal use of this type as an expression
1> .\main.cpp(24) : see declaration of 'Y'
1>.\main.cpp(43) : error C2059: syntax error : ')'
</pre>

Anyone seen this work in a different compiler or know of a workaround to make it compile (aside from the ones I mentioned)?

--
Joseph Dempsey
Sr. Software Engineer
joseph_r_dempsey@yahoo.com
<div class="modified">modified on Friday, November 5, 2010 2:18 PM</div>

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.